messageHandler, changing project name slightly
This commit is contained in:
@ -24,21 +24,26 @@ func createAudio(msg string) (filename string, file *bytes.Reader) {
|
||||
return
|
||||
}
|
||||
|
||||
func MessageHelp(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
if m.Content == "/ggd help" {
|
||||
// build list of possible commands
|
||||
return
|
||||
func MessageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
for alias, command := range CommandRegister {
|
||||
if strings.HasPrefix(m.Content, alias) {
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
var message string = strings.TrimPrefix(m.Content, alias)
|
||||
fmt.Println(message)
|
||||
command(s, m, message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func MessagePing(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
func MessageHelp(s *discordgo.Session, m *discordgo.MessageCreate, message string) {
|
||||
// build list of possible commands
|
||||
fmt.Println(message)
|
||||
return
|
||||
}
|
||||
|
||||
func MessagePing(s *discordgo.Session, m *discordgo.MessageCreate, message string) {
|
||||
if m.Content == "ping" {
|
||||
s.ChannelMessageSend(m.ChannelID, "Pong!")
|
||||
}
|
||||
@ -48,15 +53,8 @@ func MessagePing(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
}
|
||||
}
|
||||
|
||||
func MessageAudio(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
var prefix string = "/ggd tts"
|
||||
if strings.HasPrefix(m.Content, prefix) {
|
||||
var message string = strings.TrimPrefix(m.Content, prefix)
|
||||
var cleanMessage string = prepareTTSMessage(message)
|
||||
filename, file := createAudio(cleanMessage)
|
||||
s.ChannelFileSend(m.ChannelID, filename, file)
|
||||
}
|
||||
func MessageAudio(s *discordgo.Session, m *discordgo.MessageCreate, message string) {
|
||||
var cleanMessage string = prepareTTSMessage(message)
|
||||
filename, file := createAudio(cleanMessage)
|
||||
s.ChannelFileSend(m.ChannelID, filename, file)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user