|
1 | 1 | package main |
2 | 2 |
|
3 | | -import( |
4 | | - "os/exec" |
5 | | - "fmt" |
6 | | - "strings" |
7 | | - "os" |
8 | | - "math/rand" |
9 | | - "time" |
10 | | - ) |
11 | | - |
12 | | -func main(){ |
13 | | - output1,err := exec.Command("who").Output() |
14 | | - output2 := os.Getenv("USER") |
15 | | - users := string(output1[:]) |
16 | | - current_user := string(output2[:]) |
17 | | - if(!strings.Contains(users,current_user)){ |
18 | | - return |
19 | | - } |
20 | | - |
21 | | - |
22 | | - reasons := []string {"Working hard","Gotta ship this feature","Someone fucked the system again"} |
23 | | - |
24 | | - rand.Seed(time.Now().UTC().UnixNano()) |
25 | | - message := "Late at work. " + reasons[rand.Intn(len(reasons))] |
26 | | - |
27 | | - TWILIO_ACCOUNT_SID := string(os.Getenv("TWILIO_ACCOUNT_SID")) |
28 | | - TWILIO_AUTH_TOKEN := string(os.Getenv("TWILIO_AUTH_TOKEN")) |
29 | | - MY_NUMBER := string(os.Getenv("MY_NUMBER")) |
30 | | - HER_NUMBER := string(os.Getenv("HER_NUMBER")) |
31 | | - |
32 | | - response,err := exec.Command("curl","-fSs","-u",TWILIO_ACCOUNT_SID + ":" + TWILIO_AUTH_TOKEN, "-d", "From=" + MY_NUMBER, "-d", "To=" + HER_NUMBER, "-d" , "Body=" + message, "https://api.twilio.com/2010-04-01/Accounts/" + TWILIO_ACCOUNT_SID + "/Messages").Output() |
33 | | - if(err != nil){ |
34 | | - fmt.Printf("Failed to send SMS: %s",err) |
35 | | - return |
36 | | - } |
37 | | - |
38 | | - fmt.Printf("Message Sent Successfully with response: %s ",response) |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "math/rand" |
| 6 | + "os" |
| 7 | + "os/exec" |
| 8 | + "strings" |
| 9 | + "time" |
| 10 | +) |
| 11 | + |
| 12 | +func main() { |
| 13 | + output1, err := exec.Command("who").Output() |
| 14 | + output2 := os.Getenv("USER") |
| 15 | + users := string(output1[:]) |
| 16 | + current_user := string(output2[:]) |
| 17 | + if !strings.Contains(users, current_user) { |
| 18 | + return |
| 19 | + } |
| 20 | + |
| 21 | + reasons := []string{"Working hard", "Gotta ship this feature", "Someone fucked the system again"} |
| 22 | + |
| 23 | + rand.Seed(time.Now().UTC().UnixNano()) |
| 24 | + message := "Late at work. " + reasons[rand.Intn(len(reasons))] |
| 25 | + |
| 26 | + TWILIO_ACCOUNT_SID := string(os.Getenv("TWILIO_ACCOUNT_SID")) |
| 27 | + TWILIO_AUTH_TOKEN := string(os.Getenv("TWILIO_AUTH_TOKEN")) |
| 28 | + MY_NUMBER := string(os.Getenv("MY_NUMBER")) |
| 29 | + HER_NUMBER := string(os.Getenv("HER_NUMBER")) |
| 30 | + |
| 31 | + response, err := exec.Command("curl", "-fSs", "-u", TWILIO_ACCOUNT_SID+":"+TWILIO_AUTH_TOKEN, "-d", "From="+MY_NUMBER, "-d", "To="+HER_NUMBER, "-d", "Body="+message, "https://api.twilio.com/2010-04-01/Accounts/"+TWILIO_ACCOUNT_SID+"/Messages").Output() |
| 32 | + if err != nil { |
| 33 | + fmt.Printf("Failed to send SMS: %s", err) |
| 34 | + return |
| 35 | + } |
| 36 | + |
| 37 | + fmt.Printf("Message Sent Successfully with response: %s ", response) |
39 | 38 | } |
0 commit comments