diff options
author | Lance Stout <lancestout@gmail.com> | 2011-03-23 10:00:32 -0400 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2011-03-23 10:00:32 -0400 |
commit | 833f95b53af47903d8e4281e8d5668a5addc2383 (patch) | |
tree | dae184a3d13958d5d06b2e8a5f5759f30cb881be /sleekxmpp/plugins/xep_0249/invite.py | |
parent | 4b1fadde4bd87a8763131165701c08a3035005eb (diff) | |
download | slixmpp-833f95b53af47903d8e4281e8d5668a5addc2383.tar.gz slixmpp-833f95b53af47903d8e4281e8d5668a5addc2383.tar.bz2 slixmpp-833f95b53af47903d8e4281e8d5668a5addc2383.tar.xz slixmpp-833f95b53af47903d8e4281e8d5668a5addc2383.zip |
Cleaned XEP-0249 plugin, added tests.
Diffstat (limited to 'sleekxmpp/plugins/xep_0249/invite.py')
-rw-r--r-- | sleekxmpp/plugins/xep_0249/invite.py | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/sleekxmpp/plugins/xep_0249/invite.py b/sleekxmpp/plugins/xep_0249/invite.py index 7c966f15..fdeffdea 100644 --- a/sleekxmpp/plugins/xep_0249/invite.py +++ b/sleekxmpp/plugins/xep_0249/invite.py @@ -1,5 +1,10 @@ -"""Direct MUC Invitation.""" +""" + SleekXMPP: The Sleek XMPP Library + Copyright (C) 2011 Nathanael C. Fritz, Dalek + This file is part of SleekXMPP. + See the file LICENSE for copying permission. +""" import logging @@ -11,6 +16,7 @@ from sleekxmpp.xmlstream.handler import Callback from sleekxmpp.xmlstream.matcher import StanzaPath from sleekxmpp.plugins.xep_0249 import Invite + log = logging.getLogger(__name__) @@ -34,15 +40,14 @@ class xep_0249(base_plugin): def post_init(self): base_plugin.post_init(self) - self.xmpp.plugin['xep_0030'].add_feature(Invite.namespace) + self.xmpp['xep_0030'].add_feature(Invite.namespace) - def _handle_invite(self, message): + def _handle_invite(self, msg): """ Raise an event for all invitations received. - """ log.debug("Received direct muc invitation from %s to room %s", - message['from'], message['groupchat_invite']['jid']) + msg['from'], msg['groupchat_invite']['jid']) self.xmpp.event('groupchat_direct_invite', message) @@ -52,24 +57,23 @@ class xep_0249(base_plugin): Send a direct MUC invitation to an XMPP entity. Arguments: - jid -- The jid of the entity to which the inviation - is sent - roomjid -- the address of the groupchat room to be joined - password -- a password needed for entry into a - password-protected room (OPTIONAL). - reason -- a human-readable purpose for the invitation - (OPTIONAL). - + jid -- The JID of the entity that will receive + the invitation + roomjid -- the address of the groupchat room to be joined + password -- a password needed for entry into a + password-protected room (OPTIONAL). + reason -- a human-readable purpose for the invitation + (OPTIONAL). """ - message = self.xmpp.Message() - message['to'] = jid + msg = self.xmpp.Message() + msg['to'] = jid if ifrom is not None: - message['from'] = ifrom - message['groupchat_invite']['jid'] = roomjid + msg['from'] = ifrom + msg['groupchat_invite']['jid'] = roomjid if password is not None: - message['groupchat_invite']['password'] = password + msg['groupchat_invite']['password'] = password if reason is not None: - message['groupchat_invite']['reason'] = reason + msg['groupchat_invite']['reason'] = reason - return message.send() + return msg.send() |