Commit 45e22f01 authored by mathieui's avatar mathieui

Fixes #2335

parent ce1c6e4e
from plugin import BasePlugin
import tabs
from common import parse_secs_to_str
from sleekxmpp.xmlstream import ET
from sleekxmpp.xmlstream.stanzabase import JID
class Plugin(BasePlugin):
def init(self):
self.add_command('uptime', self.command_uptime, '/uptime [jid]\nUptime: Ask for the uptime of a server or component (see XEP-0012).', None)
def command_uptime(self, arg):
def callback(iq):
for query in iq.xml.getiterator('{jabber:iq:last}query'):
self.core.information('Server %s online since %s' % (iq['from'], parse_secs_to_str(int(query.attrib['seconds']))), 'Info')
self.core.information('Could not retrieve uptime', 'Error')
jid = JID(arg)
if not jid.server:
iq = self.core.xmpp.makeIqGet(ito=jid.server)
iq.send(block=False, callback=callback)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment