Tidy up logging calls.
[slixmpp.git] / sleekxmpp / plugins / xep_0085 / chat_states.py
blobe95434d235a77ec226c285e89fe1d53c84056c5a
1 """
2 SleekXMPP: The Sleek XMPP Library
3 Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout
4 This file is part of SleekXMPP.
6 See the file LICENSE for copying permissio
7 """
9 import logging
11 import sleekxmpp
12 from sleekxmpp.stanza import Message
13 from sleekxmpp.xmlstream.handler import Callback
14 from sleekxmpp.xmlstream.matcher import StanzaPath
15 from sleekxmpp.xmlstream import register_stanza_plugin, ElementBase, ET
16 from sleekxmpp.plugins.base import base_plugin
17 from sleekxmpp.plugins.xep_0085 import stanza, ChatState
20 log = logging.getLogger(__name__)
23 class xep_0085(base_plugin):
25 """
26 XEP-0085 Chat State Notifications
27 """
29 def plugin_init(self):
30 self.xep = '0085'
31 self.description = 'Chat State Notifications'
32 self.stanza = stanza
34 for state in ChatState.states:
35 self.xmpp.register_handler(
36 Callback('Chat State: %s' % state,
37 StanzaPath('message@chat_state=%s' % state),
38 self._handle_chat_state))
40 register_stanza_plugin(Message, ChatState)
42 def post_init(self):
43 base_plugin.post_init(self)
44 self.xmpp.plugin['xep_0030'].add_feature(ChatState.namespace)
46 def _handle_chat_state(self, msg):
47 state = msg['chat_state']
48 log.debug("Chat State: %s, %s", state, msg['from'].jid)
49 self.xmpp.event('chatstate_%s' % state, msg)