diff options
author | mathieui <mathieui@mathieui.net> | 2014-04-14 22:32:34 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2014-04-14 22:32:34 +0200 |
commit | 3221534b0f77a00043032c1e350814f607a56380 (patch) | |
tree | 6c7bd391e3c2e70c40efdb0c0249d676036899a3 /src/core/handlers.py | |
parent | 245f5f050cd1b72f365a21c57d3462ed5207e0cc (diff) | |
download | poezio-3221534b0f77a00043032c1e350814f607a56380.tar.gz poezio-3221534b0f77a00043032c1e350814f607a56380.tar.bz2 poezio-3221534b0f77a00043032c1e350814f607a56380.tar.xz poezio-3221534b0f77a00043032c1e350814f607a56380.zip |
Implement XEP-0249 (Direct MUC Invitations)
- fallback to mediated invitations if only the bare jid is given to the
command or if the jid does not advertise support
TODO: provide a way to send passwords
Diffstat (limited to 'src/core/handlers.py')
-rw-r--r-- | src/core/handlers.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/core/handlers.py b/src/core/handlers.py index 076bd986..b0256246 100644 --- a/src/core/handlers.py +++ b/src/core/handlers.py @@ -76,7 +76,10 @@ def on_carbon_sent(self, message): ### Invites ### -def on_groupchat_invite(self, message): +def on_groupchat_invitation(self, message): + """ + Mediated invitation received + """ jid = message['from'] if jid.bare in self.pending_invites: return @@ -97,8 +100,37 @@ def on_groupchat_invite(self, message): self.pending_invites[jid.bare] = inviter.full def on_groupchat_decline(self, decline): + "Mediated invitation declined; skip for now" pass +def on_groupchat_direct_invitation(self, message): + """ + Direct invitation received + """ + room = safeJID(message['groupchat_invite']['jid']) + if room.bare in self.pending_invites: + return + + inviter = message['from'] + reason = message['groupchat_invite']['reason'] + password = message['groupchat_invite']['password'] + continue_ = message['groupchat_invite']['continue'] + msg = "You are invited to the room %s by %s" % (room, inviter.full) + + if password: + msg += ' (password: "%s")' % password + if continue_: + msg += '\nto continue the discussion' + if reason: + msg += "\nreason: %s" % reason + + self.information(msg, 'Info') + if 'invite' in config.get('beep_on', 'invite').split(): + curses.beep() + + self.pending_invites[room.bare] = inviter.full + logger.log_roster_change(inviter.full, 'invited you to %s' % room.bare) + ### "classic" messages ### def on_message(self, message): |