Compare commits

...

3 Commits

Author SHA1 Message Date
skeletable 051fdd0f1b event check 2022-10-28 15:08:32 +02:00
skeletable 1184994799 announce the winner 2022-10-28 15:02:25 +02:00
skeletable e3f3f75a10 automatically end event 2022-10-28 14:37:00 +02:00
1 changed files with 20 additions and 11 deletions

31
main.go
View File

@ -28,6 +28,7 @@ var (
)
var url_regexp, _ = regexp.Compile(`https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)`)
var event = false
// The list of games is currently a hardcoded slice of slices. The first element of
// a game slice should be the default ("display") name of the game, second one is a short name, the other ones are aliases.
@ -667,9 +668,13 @@ func checkGame(s string) (bool, string, string) {
// message is created on any channel that the authenticated bot has access to.
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
// Ignore all messages created by the bot itself
// This isn't required in this specific example but it's a good practice.
if time.Now().Month().String() == "October" {
event = true
} else if event == true {
haul, winner := topUserCandy()
s.ChannelMessageSend("947540183077748820", "<@" + winner + "> has won the candy hunt! Candy claimed: " + fmt.Sprint(haul))
event = false
}
var claimed bool
var tickrate time.Duration
const maxtickrate = 5000 * time.Millisecond
@ -785,14 +790,14 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
return
}
// if m.ChannelID == "946459086554275883" {
// rand.Seed(time.Now().Unix())
// if rand.Intn(100) < 3 {
// time.Sleep(1 * time.Second)
// rand.Seed(time.Now().Unix() - rand.Int63n(time.Now().Unix()))
// candy(s, m.ChannelID, "")
// }
// }
if m.ChannelID == "946459086554275883" && event {
rand.Seed(time.Now().Unix())
if rand.Intn(100) < 3 {
time.Sleep(1 * time.Second)
rand.Seed(time.Now().Unix() - rand.Int63n(time.Now().Unix()))
candy(s, m.ChannelID, "")
}
}
if strings.HasPrefix(m.Content, "pp!") {
blockfile, err := ioutil.ReadFile("blocklist.txt")
@ -1367,4 +1372,8 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
AllowedMentions: &discordgo.MessageAllowedMentions{},
})
}
if strings.HasPrefix(m.Content, "pp!event") {
s.ChannelMessageSend(m.ChannelID, fmt.Sprint(event))
}
}