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_subscribe.go

52 lines
991 B
Go
Raw Normal View History

2018-12-14 23:46:58 +01:00
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
}