26 lines
563 B
Go
26 lines
563 B
Go
package schalter
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gosrc.io/xmpp"
|
|
"gosrc.io/xmpp/stanza"
|
|
)
|
|
|
|
func (s *Schalter) HandleBotMessage(c xmpp.Sender, msg stanza.Message) error {
|
|
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)
|
|
}
|
|
return c.Send(reply)
|
|
}
|
|
return fmt.Errorf("not handled by this bot: %v", msg)
|
|
}
|