mirror of
https://github.com/idanoo/NZCovidBot
synced 2025-07-02 11:42:15 +00:00
Pulls from git and posts to discord
This commit is contained in:
parent
d63f121871
commit
b37a425589
12 changed files with 611 additions and 5 deletions
60
internal/nzcovidbot/nzcovidbot.go
Normal file
60
internal/nzcovidbot/nzcovidbot.go
Normal 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{}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue