Make a thing worth running #7
4 changed files with 149 additions and 2 deletions
10
go.mod
Normal file
10
go.mod
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
module git.bunk.computer/bunk/smsbb
|
||||||
|
|
||||||
|
go 1.21.4
|
||||||
|
|
||||||
|
require github.com/twilio/twilio-go v1.16.0
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/golang/mock v1.6.0 // indirect
|
||||||
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
|
)
|
50
go.sum
Normal file
50
go.sum
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A=
|
||||||
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||||
|
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
||||||
|
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||||
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/localtunnel/go-localtunnel v0.0.0-20170326223115-8a804488f275 h1:IZycmTpoUtQK3PD60UYBwjaCUHUP7cML494ao9/O8+Q=
|
||||||
|
github.com/localtunnel/go-localtunnel v0.0.0-20170326223115-8a804488f275/go.mod h1:zt6UU74K6Z6oMOYJbJzYpYucqdcQwSMPBEdSvGiaUMw=
|
||||||
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||||
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/twilio/twilio-go v1.16.0 h1:NabGDInWQYPFVAz2TPxpjfPFeoDlaB3MIww1PlZU+rM=
|
||||||
|
github.com/twilio/twilio-go v1.16.0/go.mod h1:tdnfQ5TjbewoAu4lf9bMsGvfuJ/QU9gYuv9yx3TSIXU=
|
||||||
|
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
42
readme.md
42
readme.md
|
@ -1,10 +1,48 @@
|
||||||
# smsbb 👼
|
# smsbb 👼
|
||||||
|
|
||||||
✨ DIY sms announce lists for you and yours ✨
|
✨ DIY sms announce lists for you and yours ✨
|
||||||
|
|
||||||
## norms for working on this repo
|
## norms for working on this repo
|
||||||
|
|
||||||
- work in a branch
|
- work in a branch
|
||||||
- branch names should use the format `username/thing-you-are-doing`
|
- branch names should use the format `username/thing-you-are-doing`
|
||||||
- for example `git checkout -b maren/update-readme-3`
|
- for example `git checkout -b maren/update-readme-3`
|
||||||
- don't worry about tidy commits! just keep your work in a branch
|
- don't worry about tidy commits! just keep your work in a branch
|
||||||
- open a PR and review with someone synchronously before merging to main
|
- open a PR and review with someone synchronously before merging to main
|
||||||
|
|
||||||
|
## getting started real fast
|
||||||
|
|
||||||
|
Here's what to do if you haven't already set up your `GOPATH`:
|
||||||
|
|
||||||
|
1. Run `go env` and figure out how your Go installation is configured
|
||||||
|
with respect to your `GOPATH`:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ go env | grep GOPATH
|
||||||
|
GOPATH='/home/you/go'
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Set up this repository within your `GOPATH`:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# If GOPATH is /home/you/go, then...
|
||||||
|
$ cd ~/go && mkdir -p pkg/git.bunk.computer/bunk/smsbb && cd pkg/git.bunk.computer/bunk
|
||||||
|
$ git clone https://git.bunk.computer/bunk/smsbb
|
||||||
|
$ cd smsbb
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Get your Twilio Account SID and Auth Token and store them in the following environment
|
||||||
|
variables:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ export SMSBB_ACCT_SID="..." # Your Twilio Account SID goes here
|
||||||
|
$ export SMSBB_AUTH_TOKEN="..." # Your Twilio Auth Token goes here
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Run `smsbb`:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# In this example, +1 (828) 555-0123 is the "from" address, and
|
||||||
|
# +1 (828) 555-4567 is the "to" address
|
||||||
|
$ go run smsbb.go "+18285550123" "+18285554567" "This is your first message\!"
|
||||||
|
```
|
||||||
|
|
49
smsbb.go
Normal file
49
smsbb.go
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/twilio/twilio-go"
|
||||||
|
|
||||||
|
twilioApi "github.com/twilio/twilio-go/rest/api/v2010"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main () {
|
||||||
|
accountSid := os.Getenv("SMSBB_ACCT_SID")
|
||||||
|
authToken := os.Getenv("SMSBB_AUTH_TOKEN")
|
||||||
|
|
||||||
|
if (len(accountSid) == 0) {
|
||||||
|
fmt.Fprintf(os.Stderr, "Please set the SMSBB_ACCT_SID environment variable to your Twilio account SID\n")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len(authToken) == 0) {
|
||||||
|
fmt.Fprintf(os.Stderr, "Please set the SMSBB_AUTH_TOKEN environment variable to your Twilio authentication token\n")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len(os.Args) < 4) {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s FROM-NUMBER TO-NUMBER MESSAGE-BODY\n", os.Args[0])
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
client := twilio.NewRestClientWithParams(twilio.ClientParams{
|
||||||
|
Username: accountSid,
|
||||||
|
Password: authToken,
|
||||||
|
})
|
||||||
|
|
||||||
|
params := &twilioApi.CreateMessageParams{}
|
||||||
|
params.SetFrom(os.Args[1])
|
||||||
|
params.SetTo(os.Args[2])
|
||||||
|
params.SetBody(os.Args[3])
|
||||||
|
|
||||||
|
resp, err := client.Api.CreateMessage(params)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error sending SMS message: %s", err.Error())
|
||||||
|
} else {
|
||||||
|
response, _ := json.Marshal(*resp)
|
||||||
|
fmt.Printf("Response from Twilio: %s", string(response))
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue