2
0
mirror of https://github.com/narkoz/hacker-scripts synced 2025-08-22 18:37:10 +00:00
hacker-scripts/go/hangover.go
2015-11-30 15:42:20 +05:30

48 lines
1.0 KiB
Go

package main
import (
"fmt"
"log"
"math/rand"
"os"
"github.com/codeskyblue/go-sh"
"github.com/subosito/twilio"
)
const my_number string = "+xxxxx"
const boss_number string = "+yyyyy"
func main() {
//exit if sessions with my username are found
_, err := sh.Command("who").Command("grep", "my_username").Output()
if err != nil {
os.Exit(1)
}
//Grab Twilio ID and token from environment variables
Account_Sid := os.Getenv("TWILIO_ACCOUNT_SID")
Auth_Token := os.Getenv("TWILIO_AUTH_TOKEN")
//create the reasons slice and append reasons to it
reasons := make([]string, 0)
reasons = append(reasons,
"Locked out",
"Pipes broke",
"Food poisoning",
"Not feeling well")
// Initialize Twilio client and send message
client := twilio.NewClient(Account_Sid, Auth_Token, nil)
message := fmt.Sprint("Gonna work from home...", reasons[rand.Intn(len(reasons))])
params := twilio.MessageParams{
Body: message,
}
s, resp, err := client.Messages.Send(my_number, boss_number, params)
if err == nil {
log.Fatal(s, resp, err)
}
}