Skip to content

Commit 9415c0b

Browse files
committed
Added text reminder util
1 parent 2490597 commit 9415c0b

File tree

5 files changed

+71
-2
lines changed

5 files changed

+71
-2
lines changed

.gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# K8 BUILDER
2+
13
/k8-builder/target
24
/k8-builder/*.yaml
3-
/k8-builder/*.conf
5+
/k8-builder/*.conf
6+
7+
8+
# TEXT REMINDER #
9+
/text-reminder/config.go

docker-redo/docker-redo.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
usage="use like this: \$source docker-redo.sh -n NAME -r \"ARG ARG\" -i IMAGE"
2+
usage="use like this: \$ ./docker-redo.sh -n NAME -r \"ARG ARG\" -i IMAGE"
33
arg_error="ERROR: invalid arguments. for help run \$source docker-redo.sh -h"
44
image_error="ERROR: you must specify an image"
55

text-reminder/Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM golang:1.11.0
2+
3+
RUN mkdir /app
4+
ADD . /app/
5+
WORKDIR /app
6+
7+
RUN go get github.com/jasonlvhit/gocron
8+
RUN go get github.com/sfreiberg/gotwilio
9+
RUN go build -o main
10+
CMD ["./main"]
11+

text-reminder/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Text Reminder
2+
3+
This program sends a text at the same time each day.
4+
5+
## Getting Started
6+
7+
create the file 'config.go'
8+
```
9+
package main
10+
11+
const sid = "" // twilio account sid
12+
const token = "" // twilio auth token
13+
const from = "" // sender's number, format: "+15558889999"
14+
const reminderTime = "" // time of day to send reminder (UTC), format: 21:00
15+
const to = "" // receiver's number
16+
const message = "" // message to send
17+
```
18+
19+
## Build Docker
20+
21+
```
22+
docker build -t spoofardio/text-reminder:1.0.0 .
23+
```
24+
25+
```
26+
docker run -d --restart=unless-stopped /
27+
--name=text-reminder spoofardio/text-reminder:1.0.0
28+
```

text-reminder/main.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package main
2+
3+
import (
4+
"log"
5+
"time"
6+
7+
"github.com/jasonlvhit/gocron"
8+
"github.com/sfreiberg/gotwilio"
9+
)
10+
11+
var twilio *gotwilio.Twilio
12+
13+
func main() {
14+
twilio = gotwilio.NewTwilioClient(sid, token)
15+
log.Println("Reminder Service Started : ", time.Now().Format("2006-Jan-02"))
16+
gocron.Every(1).Day().At(reminderTime).Do(sendText)
17+
<-gocron.Start()
18+
}
19+
20+
func sendText() {
21+
22+
twilio.SendSMS(from, to, message, "", "")
23+
log.Println("Message Sent : ", time.Now().Format("2006-Jan-02"))
24+
}

0 commit comments

Comments
 (0)