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
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
):
26 XEP-0085 Chat State Notifications
29 def plugin_init(self
):
31 self
.description
= 'Chat State Notifications'
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
)
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
)