From de8630c13625da6654e01d6a068116c53b193202 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 22 Feb 2026 15:26:45 -0700 Subject: [PATCH] fix(cmd/sendsms): send messages again (but not on dry-run), check ENVs --- cmd/sendsms/example.env | 1 + cmd/sendsms/sendsms.go | 14 +++++++++++++- cmd/sendsms/smsgatewayforandroid.go | 4 ---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cmd/sendsms/example.env b/cmd/sendsms/example.env index 7a15f8e..a7a796c 100644 --- a/cmd/sendsms/example.env +++ b/cmd/sendsms/example.env @@ -1,3 +1,4 @@ +#!/bin/sh #export SMSGW_BASEURL=http://192.168.1.200:8080 export SMSGW_BASEURL=https://smsgateway.example.com export SMSGW_USERNAME=sms diff --git a/cmd/sendsms/sendsms.go b/cmd/sendsms/sendsms.go index 7e7b868..eee91cc 100644 --- a/cmd/sendsms/sendsms.go +++ b/cmd/sendsms/sendsms.go @@ -95,6 +95,18 @@ func main() { username: os.Getenv("SMSGW_USERNAME"), password: os.Getenv("SMSGW_PASSWORD"), } + if os.Getenv("SMSGW_BASEURL") == "" { + fmt.Fprintf(os.Stderr, "\n%sError%s: SMSGW_BASEURL is not set\n", textErr, textReset) + os.Exit(1) + } + if os.Getenv("SMSGW_USERNAME") == "" { + fmt.Fprintf(os.Stderr, "\n%sError%s: SMSGW_USERNAME is not set\n", textErr, textReset) + os.Exit(1) + } + if os.Getenv("SMSGW_PASSWORD") == "" { + fmt.Fprintf(os.Stderr, "\n%sError%s: SMSGW_PASSWORD is not set\n", textErr, textReset) + os.Exit(1) + } // TODO add days of week // TODO add start time zone and end time zone for whole country (e.g. 9am ET to 8pm PT) @@ -305,7 +317,7 @@ func main() { } if i > 0 { - if cfg.dryRun || cfg.printCurl { + if cfg.dryRun { fmt.Printf("sleep %s\n\n", delay.Round(time.Millisecond)) } else { time.Sleep(delay) diff --git a/cmd/sendsms/smsgatewayforandroid.go b/cmd/sendsms/smsgatewayforandroid.go index 8d17fe5..046f8bf 100644 --- a/cmd/sendsms/smsgatewayforandroid.go +++ b/cmd/sendsms/smsgatewayforandroid.go @@ -43,10 +43,6 @@ func (s *SMSGatewayForAndroid) CurlString(number, message string) string { } func (s *SMSGatewayForAndroid) Send(number, message string) error { - if true { - return fmt.Errorf("didn't send") - } - number = cleanPhoneNumber(number) if len(number) == 0 { panic(fmt.Errorf("non-sanitized number '%s'", number))