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 }