def onPrecenceUpdated(self, jid, lastseen): buddy = jid.split("@")[0] self.logger.info("Lastseen: %s %s", buddy, utils.ago(lastseen)) if buddy in self.presenceRequested: timestamp = time.localtime(time.time() - lastseen) timestring = time.strftime("%a, %d %b %Y %H:%M:%S", timestamp) self.sendMessageToXMPP(buddy, "%s (%s)" % (timestring, utils.ago(lastseen))) self.presenceRequested.remove(buddy) if lastseen < 60: self.onPrecenceAvailable(jid) else: self.onPrecenceUnavailable(jid)
def onPrecenceUpdated(self, jid, lastseen): buddy = jid.split("@")[0] self.logger.info("Lastseen: %s %s", buddy, utils.ago(lastseen)) if buddy in self.presenceRequested: timestamp = time.localtime(time.time() - lastseen) timestring = time.strftime("%a, %d %b %Y %H:%M:%S", timestamp) self.sendMessageToXMPP( buddy, "%s (%s)" % (timestring, utils.ago(lastseen))) self.presenceRequested.remove(buddy) if lastseen < 60: self.onPrecenceAvailable(jid) else: self.onPrecenceUnavailable(jid)
def status(self): if self.updating: return "updating" if self.updated is None: return "never updated" if self.is_stale: return "stale" return "updated %s" % ago(self.updated)
def onPresenceReceived(self, _type, name, jid, lastseen): self.logger.info("Presence received: %s %s %s %s", _type, name, jid, lastseen) buddy = jid.split("@")[0] # seems to be causing an error # self.logger.info("Lastseen: %s %s", buddy, utils.ago(lastseen)) if buddy in self.presenceRequested: timestamp = time.localtime(time.time() - lastseen) timestring = time.strftime("%a, %d %b %Y %H:%M:%S", timestamp) self.sendMessageToXMPP( buddy, "%s (%s)" % (timestring, utils.ago(lastseen))) self.presenceRequested.remove(buddy) if lastseen < 60: self.onPresenceAvailable(buddy) else: self.onPresenceUnavailable(buddy)
def ago(self): return utils.ago(self.timestamp)
def onSuccess(buddy, lastseen): timestamp = time.localtime(time.localtime() - lastseen) timestring = time.strftime("%a, %d %b %Y %H:%M:%S", timestamp) self.sendMessageToXMPP( buddy, "%s (%s) %s" % (timestring, utils.ago(lastseen), str(lastseen)))