XMPP stats example for PyXMPP
Материал из Linux Wiki
Версия от 20:24, 11 марта 2023; Rain (обсуждение | вклад) (Новая страница: «<source lang=python> def get_stats(self, iq): # It's incorrect implementation of XEP-0039, it should be in 2 steps (like search) iq = iq.make_result_response() q = iq.new_query("http://jabber.org/protocol/stats") upt = q.newChild(None, "stat", None) upt.setProp("name", 'time/uptime') upt.setProp("units", 'seconds') upt.setProp("value", str(int(time.time()) - self.start_time)) reqsh = q.newChild(None,...»)
def get_stats(self, iq):
# It's incorrect implementation of XEP-0039, it should be in 2 steps (like search)
iq = iq.make_result_response()
q = iq.new_query("http://jabber.org/protocol/stats")
upt = q.newChild(None, "stat", None)
upt.setProp("name", 'time/uptime')
upt.setProp("units", 'seconds')
upt.setProp("value", str(int(time.time()) - self.start_time))
reqsh = q.newChild(None, "stat", None)
reqsh.setProp("name", 'messages/hourly')
reqsh.setProp("units", 'messages')
reqsh.setProp("value", str(hourly))
self.stream.send(iq)
return 1