fix(cmd/sendsms): send messages again (but not on dry-run), check ENVs

This commit is contained in:
AJ ONeal 2026-02-22 15:26:45 -07:00
parent 4e5277d133
commit de8630c136
No known key found for this signature in database
3 changed files with 14 additions and 5 deletions

View File

@ -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

View File

@ -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)

View File

@ -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))