ccchatbot/schalter/bot.go

27 lines
528 B
Go

package schalter
import (
"fmt"
"gosrc.io/xmpp"
"gosrc.io/xmpp/stanza"
)
func (s *Schalter) HandleBotMessage(c xmpp.Sender, msg stanza.Message) bool {
if msg.Body == ".status" {
jid, _ := xmpp.NewJid(msg.From)
reply := stanza.Message{
Attrs: stanza.Attrs{Type: msg.Type,
To: msg.From,
},
Body: s.stateString(),
}
if msg.Type == stanza.MessageTypeGroupchat {
reply.To = jid.Bare()
reply.Body = fmt.Sprintf("%s: %s", jid.Resource, reply.Body)
}
c.Send(reply)
return true
}
return false
}