Move XEP-0012 to new system.
Still needs to update to the current plugin format though.
This commit is contained in:
parent
d104a5fe75
commit
6f337b5425
@ -9,11 +9,11 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from . import base
|
from sleekxmpp.plugins import BasePlugin, register_plugin
|
||||||
from .. stanza.iq import Iq
|
from sleekxmpp import Iq
|
||||||
from .. xmlstream.handler.callback import Callback
|
from sleekxmpp.xmlstream.handler.callback import Callback
|
||||||
from .. xmlstream.matcher.xpath import MatchXPath
|
from sleekxmpp.xmlstream.matcher.xpath import MatchXPath
|
||||||
from .. xmlstream import ElementBase, ET, JID, register_stanza_plugin
|
from sleekxmpp.xmlstream import ElementBase, ET, JID, register_stanza_plugin
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -40,12 +40,18 @@ class LastActivity(ElementBase):
|
|||||||
def del_status(self):
|
def del_status(self):
|
||||||
self.xml.text = ''
|
self.xml.text = ''
|
||||||
|
|
||||||
class xep_0012(base.base_plugin):
|
|
||||||
|
class XEP_0012(BasePlugin):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
XEP-0012 Last Activity
|
XEP-0012 Last Activity
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
name = 'xep_0012'
|
||||||
|
description = 'XEP-0012: Last Activity'
|
||||||
|
dependencies = set(['xep_0030'])
|
||||||
|
|
||||||
def plugin_init(self):
|
def plugin_init(self):
|
||||||
self.description = "Last Activity"
|
|
||||||
self.xep = "0012"
|
self.xep = "0012"
|
||||||
|
|
||||||
self.xmpp.registerHandler(
|
self.xmpp.registerHandler(
|
||||||
@ -57,9 +63,6 @@ class xep_0012(base.base_plugin):
|
|||||||
|
|
||||||
self.xmpp.add_event_handler('last_activity_request', self.handle_last_activity)
|
self.xmpp.add_event_handler('last_activity_request', self.handle_last_activity)
|
||||||
|
|
||||||
|
|
||||||
def post_init(self):
|
|
||||||
base.base_plugin.post_init(self)
|
|
||||||
if self.xmpp.is_component:
|
if self.xmpp.is_component:
|
||||||
# We are a component, so we track the uptime
|
# We are a component, so we track the uptime
|
||||||
self.xmpp.add_event_handler("session_start", self._reset_uptime)
|
self.xmpp.add_event_handler("session_start", self._reset_uptime)
|
||||||
@ -113,3 +116,6 @@ class xep_0012(base.base_plugin):
|
|||||||
id = iq.get('id')
|
id = iq.get('id')
|
||||||
result = iq.send()
|
result = iq.send()
|
||||||
return result['last_activity']['seconds']
|
return result['last_activity']['seconds']
|
||||||
|
|
||||||
|
|
||||||
|
register_plugin(XEP_0012)
|
||||||
|
Loading…
Reference in New Issue
Block a user