52 lines
991 B
Go
52 lines
991 B
Go
|
package bot
|
||
|
|
||
|
import (
|
||
|
"dev.sum7.eu/genofire/yaja/xmpp"
|
||
|
)
|
||
|
|
||
|
type SubscribeHander struct {
|
||
|
Handler
|
||
|
Disabled *bool
|
||
|
}
|
||
|
|
||
|
func (h *SubscribeHander) Presence(bot *Bot, pres *xmpp.PresenceClient) bool {
|
||
|
/*
|
||
|
if *(h.Disabled) {
|
||
|
return false
|
||
|
}
|
||
|
*/
|
||
|
switch pres.Type {
|
||
|
case xmpp.PresenceTypeSubscribe:
|
||
|
pres.Type = xmpp.PresenceTypeSubscribed
|
||
|
pres.To = pres.From
|
||
|
pres.From = nil
|
||
|
//accept new subscribe
|
||
|
bot.client.Send(pres)
|
||
|
|
||
|
pres.Type = xmpp.PresenceTypeSubscribe
|
||
|
pres.ID = ""
|
||
|
// request also subscribe
|
||
|
bot.client.Send(pres)
|
||
|
return true
|
||
|
case xmpp.PresenceTypeSubscribed:
|
||
|
return true
|
||
|
case xmpp.PresenceTypeUnsubscribe:
|
||
|
return true
|
||
|
case xmpp.PresenceTypeUnsubscribed:
|
||
|
return true
|
||
|
case xmpp.PresenceTypeUnavailable:
|
||
|
// ignore Unavailable messages
|
||
|
return true
|
||
|
default:
|
||
|
return false
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (h *SubscribeHander) Message(bot *Bot, msg *xmpp.MessageClient) bool {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
func (h *SubscribeHander) IQ(bot *Bot, iq *xmpp.IQClient) bool {
|
||
|
return false
|
||
|
}
|