Pulls from git and posts to discord

This commit is contained in:
Daniel Mason 2021-09-01 21:22:09 +12:00
parent d63f121871
commit b37a425589
Signed by: idanoo
GPG key ID: 387387CDBC02F132
12 changed files with 611 additions and 5 deletions

View file

@ -0,0 +1,60 @@
package nzcovidbot
import (
"fmt"
"time"
)
var Repository string
func Lesgoooo() {
// Setup repo stuff
loadRepo(Repository)
// Create chan to end timer
endTicker := make(chan bool)
// Timer to run every minute
minuteTicker := time.NewTicker(time.Duration(15) * time.Second)
// Initial check on load
go checkForUpdates()
for {
select {
case <-endTicker:
fmt.Println("Stopping background workers")
return
case <-minuteTicker.C:
// Check for updates
go checkForUpdates()
}
}
}
func postTheUpdates() {
// Discord
postableDiscordData := getPostableDiscordData()
if postableDiscordData == "" {
return
}
for _, discordWebhook := range DiscordWebhooks {
postToDiscord(discordWebhook, postableDiscordData)
}
// Twitter
// postableTwitterData := getPostableTwitterData()
// if postableTwitterData == "" {
// return
// }
// for _, discordWebhook := range DiscordWebhooks {
// postToTwitter(discordWebhook, postableTwitterData)
// }
// Clear out posted data!
updatedLocations = UpdatedLocations{}
}