sum7
/
yaja
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
yaja/bot/handler_commandmsg.go

37 lines
696 B
Go

package bot
import (
"strings"
"dev.sum7.eu/genofire/yaja/xmpp"
)
type CommandMessageHander struct {
Handler
Commands map[string]func(*Bot, *xmpp.MessageClient, string)
}
func (h *CommandMessageHander) Presence(bot *Bot, pres *xmpp.PresenceClient) bool {
return false
}
func (h *CommandMessageHander) Message(bot *Bot, msg *xmpp.MessageClient) bool {
msgText := strings.SplitN(msg.Body, " ", 2)
if msgText != nil {
cmd := msgText[0]
if f, ok := h.Commands[cmd]; ok {
args := ""
if len(msgText) >= 2 {
args = msgText[1]
}
f(bot, msg, args)
return true
}
}
return false
}
func (h *CommandMessageHander) IQ(bot *Bot, iq *xmpp.IQClient) bool {
return false
}