XMPP stats example for PyXMPP

Материал из Linux Wiki
Перейти к навигацииПерейти к поиску
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