added check for message prefix
This commit is contained in:
20
bunnybot.go
20
bunnybot.go
@@ -6,6 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
)
|
)
|
||||||
@@ -50,20 +51,21 @@ func main() {
|
|||||||
|
|
||||||
func message_create (s *discordgo.Session, m *discordgo.MessageCreate) {
|
func message_create (s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
|
|
||||||
// ignore messages by the bot
|
// make sure we match our bot's message token
|
||||||
if m.Author.ID == s.State.User.ID {
|
if len(m.Content) > 2 {
|
||||||
|
input_token := m.Content[0:2]
|
||||||
|
if strings.ToLower(string(input_token)) != "t." {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ping
|
|
||||||
if m.Content == "ping" {
|
|
||||||
s.ChannelMessageSend(m.ChannelID, "Pong!")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Content == "pong" {
|
// get our message without our bot's token
|
||||||
s.ChannelMessageSend(m.ChannelID, "Ping!")
|
message := m.Content[2:]
|
||||||
}
|
|
||||||
|
|
||||||
|
// awwnime (test)
|
||||||
|
if message == "awwnime" {
|
||||||
|
s.ChannelMessageSend(m.ChannelID, get_redditbooru("awwnime"))
|
||||||
|
}
|
||||||
|
|
||||||
//get_redditbooru("awwnime")
|
//get_redditbooru("awwnime")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user