projects
/
svn42.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
distribute DoorProblemEvent
[svn42.git]
/
go
/
r3-netstatus
/
r3xmppbot
/
r3xmppbot.go
diff --git
a/go/r3-netstatus/r3xmppbot/r3xmppbot.go
b/go/r3-netstatus/r3xmppbot/r3xmppbot.go
index
7863b70
..
293be18
100644
(file)
--- 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)
defer func() {
if x := recover(); x != nil {
Syslog_.Printf("handleEventsforXMPP: run time panic: %v", x)
+ //FIXME: signal that xmpp bot has crashed
}
}()
for {
select {
}
}()
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
switch pec := pe.(type) {
case xmpp.Stanza:
xmppout <- pec
@@
-218,11
+221,20
@@
func (botdata *XmppBot) handleEventsforXMPP(xmppout chan <- xmpp.Stanza, presenc
break
}
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]
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 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
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 {
roster := xmpp.Roster(botdata.xmppclient_)
for _, entry := range roster {
+ Debug_.Print(entry)
if entry.Subscription == "from" {
botdata.xmppclient_.Out <- botdata.makeXMPPPresence(entry.Jid, "subscribe", "","")
}
if entry.Subscription == "from" {
botdata.xmppclient_.Out <- botdata.makeXMPPPresence(entry.Jid, "subscribe", "","")
}