diff options
author | mathieui <mathieui@mathieui.net> | 2012-02-24 02:14:54 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2012-02-24 02:14:54 +0100 |
commit | 45e22f01b5f7350d47f8bdc2cc39b9b79682e72b (patch) | |
tree | 634a4d113159c8e6d841813e4733d632d9729a88 | |
parent | ce1c6e4ec6fa2585e1f9bbc620fb8510dd3b0303 (diff) | |
download | poezio-45e22f01b5f7350d47f8bdc2cc39b9b79682e72b.tar.gz poezio-45e22f01b5f7350d47f8bdc2cc39b9b79682e72b.tar.bz2 poezio-45e22f01b5f7350d47f8bdc2cc39b9b79682e72b.tar.xz poezio-45e22f01b5f7350d47f8bdc2cc39b9b79682e72b.zip |
Fixes #2335
-rw-r--r-- | plugins/uptime.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/uptime.py b/plugins/uptime.py new file mode 100644 index 00000000..ca79ce84 --- /dev/null +++ b/plugins/uptime.py @@ -0,0 +1,22 @@ +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') + return + self.core.information('Could not retrieve uptime', 'Error') + jid = JID(arg) + if not jid.server: + return + iq = self.core.xmpp.makeIqGet(ito=jid.server) + iq.append(ET.Element('{jabber:iq:last}query')) + iq.send(block=False, callback=callback) |