diff src/plugins/plugin_xep_0249.py @ 1384:73f8582c7c99

plugins XEP-0045, XEP-0249: allow to join / invite without specifying the JID's host part (use client's values)
author souliane <souliane@mailoo.org>
date Tue, 24 Mar 2015 07:34:32 +0100
parents 6d0e01809893
children 069ad98b360d
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0249.py	Mon Mar 23 09:34:23 2015 +0100
+++ b/src/plugins/plugin_xep_0249.py	Tue Mar 24 07:34:32 2015 +0100
@@ -171,18 +171,17 @@
         @command (group): JID
             - JID: the JID of the person to invite
         """
-        jid_s = mess_data["unparsed"].strip()
+        contact_jid_s = mess_data["unparsed"].strip()
+        my_host = self.host.profiles[profile].jid.host
         try:
-            assert jid_s
-            jid_ = jid.JID(jid_s)
-            assert jid_.user
-            assert jid_.host
-        except (jid.InvalidFormat, AssertionError):
-            feedback = _(u"You must provide a valid JID to invite, like in '/invite contact@example.net'")
+            contact_jid = jid.JID(contact_jid_s)
+        except (RuntimeError, jid.InvalidFormat, AttributeError):
+            feedback = _(u"You must provide a valid JID to invite, like in '/invite contact@{host}'").format(host=my_host)
             self.host.plugins[C.TEXT_CMDS].feedBack(feedback, mess_data, profile)
             return False
-
-        self.invite(jid_, mess_data["to"], {}, profile)
+        if not contact_jid.user:
+            contact_jid.user, contact_jid.host = contact_jid.host, my_host
+        self.invite(contact_jid, mess_data["to"], {}, profile)
         return False