# HG changeset patch # User Goffi # Date 1622735981 -7200 # Node ID ae5f63e5ed2cd06b09117d0cdb27f8db68767524 # Parent f19718296c2016e6675cc598e0af929036d931f8 plugin XEP-0045: fix `/join` text command diff -r f19718296c20 -r ae5f63e5ed2c sat/plugins/plugin_misc_text_commands.py --- a/sat/plugins/plugin_misc_text_commands.py Thu Jun 03 17:47:25 2021 +0200 +++ b/sat/plugins/plugin_misc_text_commands.py Thu Jun 03 17:59:41 2021 +0200 @@ -327,7 +327,7 @@ if arg[-1] != "@": return jid.JID(arg) return jid.JID(arg + service_jid) - return jid.JID("%s@%s" % (arg, service_jid)) + return jid.JID(f"{arg}@{service_jid}") def feedBack(self, client, message, mess_data, info_type=FEEDBACK_INFO_TYPE): """Give a message back to the user""" diff -r f19718296c20 -r ae5f63e5ed2c sat/plugins/plugin_xep_0045.py --- a/sat/plugins/plugin_xep_0045.py Thu Jun 03 17:47:25 2021 +0200 +++ b/sat/plugins/plugin_xep_0045.py Thu Jun 03 17:59:41 2021 +0200 @@ -674,10 +674,19 @@ @command (all): JID - JID: room to join (on the same service if full jid is not specified) """ - if mess_data["unparsed"].strip(): - room_jid = self.text_cmds.getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) - nick = (self.getRoomNick(client, room_jid) or - client.jid.user) + room_raw = mess_data["unparsed"].strip() + if room_raw: + if self.isJoinedRoom(client, mess_data["to"]): + # we use the same service as the one from the room where the command has + # been entered if full jid is not entered + muc_service = mess_data["to"].host + nick = self.getRoomNick(client, mess_data["to"]) or client.jid.user + else: + # the command has been entered in a one2one conversation, so we use + # our server MUC service as default service + muc_service = client.muc_service or "" + nick = client.jid.user + room_jid = self.text_cmds.getRoomJID(room_raw, muc_service) self.join(client, room_jid, nick, {}) return False @@ -688,8 +697,9 @@ @command (group): [ROOM_JID] - ROOM_JID: jid of the room to live (current room if not specified) """ - if mess_data["unparsed"].strip(): - room = self.text_cmds.getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) + room_raw = mess_data["unparsed"].strip() + if room_raw: + room = self.text_cmds.getRoomJID(room_raw, mess_data["to"].host) else: room = mess_data["to"]