From dc0ca7b469404b6f23a2f15fc41d64b82b2e06e3 Mon Sep 17 00:00:00 2001 From: Daniel Tam Date: Sat, 6 Jun 2020 03:11:53 -0500 Subject: [PATCH] added check for message prefix --- bunnybot.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/bunnybot.go b/bunnybot.go index f3bb276..e56bf43 100644 --- a/bunnybot.go +++ b/bunnybot.go @@ -6,6 +6,7 @@ import ( "os" "os/signal" "syscall" + "strings" "github.com/bwmarrin/discordgo" ) @@ -49,22 +50,23 @@ func main() { } func message_create (s *discordgo.Session, m *discordgo.MessageCreate) { - - // ignore messages by the bot - if m.Author.ID == s.State.User.ID { - return + + // make sure we match our bot's message token + if len(m.Content) > 2 { + input_token := m.Content[0:2] + if strings.ToLower(string(input_token)) != "t." { + return + } } - // ping - if m.Content == "ping" { - s.ChannelMessageSend(m.ChannelID, "Pong!") + // get our message without our bot's token + message := m.Content[2:] + + // awwnime (test) + if message == "awwnime" { + s.ChannelMessageSend(m.ChannelID, get_redditbooru("awwnime")) } - if m.Content == "pong" { - s.ChannelMessageSend(m.ChannelID, "Ping!") - } - - //get_redditbooru("awwnime") }