comparison 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
comparison
equal deleted inserted replaced
1383:59c48796759e 1384:73f8582c7c99
169 """invite someone in the room 169 """invite someone in the room
170 170
171 @command (group): JID 171 @command (group): JID
172 - JID: the JID of the person to invite 172 - JID: the JID of the person to invite
173 """ 173 """
174 jid_s = mess_data["unparsed"].strip() 174 contact_jid_s = mess_data["unparsed"].strip()
175 my_host = self.host.profiles[profile].jid.host
175 try: 176 try:
176 assert jid_s 177 contact_jid = jid.JID(contact_jid_s)
177 jid_ = jid.JID(jid_s) 178 except (RuntimeError, jid.InvalidFormat, AttributeError):
178 assert jid_.user 179 feedback = _(u"You must provide a valid JID to invite, like in '/invite contact@{host}'").format(host=my_host)
179 assert jid_.host
180 except (jid.InvalidFormat, AssertionError):
181 feedback = _(u"You must provide a valid JID to invite, like in '/invite contact@example.net'")
182 self.host.plugins[C.TEXT_CMDS].feedBack(feedback, mess_data, profile) 180 self.host.plugins[C.TEXT_CMDS].feedBack(feedback, mess_data, profile)
183 return False 181 return False
184 182 if not contact_jid.user:
185 self.invite(jid_, mess_data["to"], {}, profile) 183 contact_jid.user, contact_jid.host = contact_jid.host, my_host
184 self.invite(contact_jid, mess_data["to"], {}, profile)
186 return False 185 return False
187 186
188 187
189 class XEP_0249_handler(XMPPHandler): 188 class XEP_0249_handler(XMPPHandler):
190 implements(iwokkel.IDisco) 189 implements(iwokkel.IDisco)