mirror of
https://github.com/therootcompany/golib.git
synced 2026-03-02 23:57:59 +00:00
fix(cmd/sendsms): send messages again (but not on dry-run), check ENVs
This commit is contained in:
parent
4e5277d133
commit
de8630c136
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user