Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to shut down an entire birthdaybot.io installation for the good of mankind
// step (1) register for the free premium trial
// step (2) create a new team using the participants list of one of the default channels
// step (3) run this script
package main
import (
"fmt"
"github.com/nlopes/slack"
"time"
)
func main() {
token := "<legacy API token here>"
dmChanID := "<birthday bot's direct message channel ID here>"
targetDate := "<tomorrow's date here>"
wait := 2 * time.Second
api := slack.New(token)
users, err := api.GetUsers()
if err != nil {
fmt.Printf("getting users: %s\n", err)
return
}
params := slack.NewPostMessageParameters()
params.AsUser = true
params.LinkNames = 1
params.EscapeText = false
for _, user := range users {
channelID, timestamp, err := api.PostMessage(dmChanID, slack.MsgOptionText(fmt.Sprintf("@%s birthday is on %s", user.Name, targetDate), false), slack.MsgOptionPostMessageParameters(params))
if err != nil {
fmt.Printf("error setting birthday for user %s: %s\n", user.ID, err)
return
}
fmt.Printf("Message successfully sent to channel %s at %s: ID: %s, Name: %s\n", channelID, timestamp, user.ID, user.Name)
time.Sleep(wait)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment