X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=go%2Fr3-netstatus%2Fr3xmppbot%2Fr3xmppbot.go;h=293be184f644c09a943d3e1ebff1d31bd9eccbcb;hb=36c81737d355f02eb05b150472c9bf44fbf46120;hp=7863b70b61baf19d35a38d27ef55392eee2cf78a;hpb=b7182b7f1d5dae86d81310beaa6ce6d693696572;p=svn42.git diff --git a/go/r3-netstatus/r3xmppbot/r3xmppbot.go b/go/r3-netstatus/r3xmppbot/r3xmppbot.go index 7863b70..293be18 100644 --- a/go/r3-netstatus/r3xmppbot/r3xmppbot.go +++ b/go/r3-netstatus/r3xmppbot/r3xmppbot.go @@ -185,12 +185,15 @@ func (botdata *XmppBot) handleEventsforXMPP(xmppout chan <- xmpp.Stanza, presenc defer func() { if x := recover(); x != nil { Syslog_.Printf("handleEventsforXMPP: run time panic: %v", x) + //FIXME: signal that xmpp bot has crashed } }() for { select { - case pe := <-presence_events: + case pe, pe_still_open := <-presence_events: + if ! pe_still_open { break } + Debug_.Printf("handleEventsforXMPP<-presence_events: %T %+v", pe, pe) switch pec := pe.(type) { case xmpp.Stanza: xmppout <- pec @@ -218,11 +221,20 @@ func (botdata *XmppBot) handleEventsforXMPP(xmppout chan <- xmpp.Stanza, presenc break } - case je := <-jabber_events: + case je, je_still_open := <-jabber_events: + if ! je_still_open { break } + Debug_.Printf("handleEventsforXMPP<-jabber_events: %T %+v", je, je) simple_jid := removeJIDResource(je.JID) jid_data, jid_in_map := botdata.realraum_jids_[simple_jid] + + //send status if requested, even if user never changed any settings and thus is not in map + if last_status_msg != nil && je.StatusNow { + xmppout <- botdata.makeXMPPMessage(je.JID, last_status_msg, nil) + } + if jid_in_map { - if last_status_msg != nil && (je.StatusNow || (! jid_data.Online && je.Online && jid_data.Wants == R3OnlineOnlyWithRecapInfo) ) { + //if R3OnlineOnlyWithRecapInfo, we want a status update when coming online + if last_status_msg != nil && ! jid_data.Online && je.Online && jid_data.Wants == R3OnlineOnlyWithRecapInfo { xmppout <- botdata.makeXMPPMessage(je.JID, last_status_msg, nil) } jid_data.Online = je.Online @@ -388,6 +400,7 @@ func NewStartedBot(loginjid, loginpwd, password, state_save_dir string, insecure roster := xmpp.Roster(botdata.xmppclient_) for _, entry := range roster { + Debug_.Print(entry) if entry.Subscription == "from" { botdata.xmppclient_.Out <- botdata.makeXMPPPresence(entry.Jid, "subscribe", "","") }