From: Frank L. <fr...@fr...> - 2009-12-03 13:11:32
|
Hello Adrian, Thanks for your reply. I followed the documentation and created the code required to use the "getStatus()" method. However, it seems that it returns "None" for most people who are online. I guess my goal here is to find a way to determine if someone is online before actually sending the message. Here is a sample of the code I created (This was just a test of the method to make sure I was using it correctly) jid = xmpp.protocol.JID('jab...@do...') cl = xmpp.Client(jid.getDomain(), debug=[]) con = cl.connect() auth = cl.auth(jid.getNode(), 'password', resource=jid.getResource()) cl.sendInitPresence() roster = cl.getRoster() jids = roster.getItems() for i in jids: print i print "Ask = %s" % roster.getAsk(i) print "Name = %s" % roster.getName(i) print "Group = %s" % roster.getGroups(i) print "Priority = %s" % roster.getPriority(i) print "Show = %s" % roster.getShow(i) print "Status = %s" % roster.getStatus(i) print "Sub = %s" % roster.getSubscription(i) print "Resources = %s" % roster.getResources(i) Everything appears to be outputting correctly, but the status is almost always "None" unless someone has specifically set it in their client. There is no indication that a user is online or offline. Thanks in advance! -Frank hornsby wrote: > hi, > > They are several functions in Class Roster that shoiuld help you do the > trick: > > getRoster(self) and getStatus(self,jid). > > > check the link: > http://xmpppy.sourceforge.net/apidocs/xmpp.roster.Roster-class.html > > > cheers, > adrian > > On Tue, 2009-12-01 at 11:02 -0500, Frank Laszlo wrote: > >> Hello, >> >> I'm currently working on a script for server monitoring, specifically >> the notification module for it. Since we use Jabber in house, I'd like >> to be able to send alerts this way. >> >> Actually sending the alerts was not difficult, however, I cannot find a >> solution to be able to verify that the person its being sent to is >> "Available." Currently, it will send it regardless of their status, but >> if they are offline, they get flooded with messages as soon as they sign >> on. >> >> I've pasted the applicable code below, if anyone could give me some >> guidance I'd greatly appreciate it. As a bit of background, jabber() is >> called with all strings as arguments. >> >> def jabber(name, jabberid, servername, load, eximcount, type): >> jid = xmpp.protocol.JID(config.jabberID) >> cl = xmpp.Client(jid.getDomain(), debug=[]) >> con = cl.connect() >> if not con: >> print "Could not connect to jabber\n" >> auth = cl.auth(jid.getNode(), config.jabberPass, >> resource=jid.getResource()) >> if not auth: >> print "Could not authenticate to jabber\n" >> if type == 'exim': >> msg = "[ALERT]: Too many messages in queue on %s >> - Current count: %s" % (servername, eximcount) >> elif type == 'load': >> msg = "[ALERT]: Processor load high on %s - >> Current load: %s" % (servername, load) >> elif type == 'down': >> msg = "[ALERT]: Server %s is unreachable. - Last >> recorded load: %s" % (servername, load) >> else: >> print "Invalid alert type: '%s'" % (type) >> id = cl.send(xmpp.protocol.Message(jabberid, msg)) >> time.sleep(1) >> print "Jabber alert message sent to %s" % (jabberid) >> >> >> >> -Frank >> >> ------------------------------------------------------------------------------ >> Join us December 9, 2009 for the Red Hat Virtual Experience, >> a free event focused on virtualization and cloud computing. >> Attend in-depth sessions from your desk. Your couch. Anywhere. >> http://p.sf.net/sfu/redhat-sfdev2dev >> _______________________________________________ >> Xmpppy-devel mailing list >> Xmp...@li... >> https://lists.sourceforge.net/lists/listinfo/xmpppy-devel >> > > > ------------------------------------------------------------------------------ > Join us December 9, 2009 for the Red Hat Virtual Experience, > a free event focused on virtualization and cloud computing. > Attend in-depth sessions from your desk. Your couch. Anywhere. > http://p.sf.net/sfu/redhat-sfdev2dev > _______________________________________________ > Xmpppy-devel mailing list > Xmp...@li... > https://lists.sourceforge.net/lists/listinfo/xmpppy-devel > |