diff --git a/sat/plugins/plugin_misc_text_commands.py b/sat/plugins/plugin_misc_text_commands.py index 51fe728f..5f9e42a6 100644 --- a/sat/plugins/plugin_misc_text_commands.py +++ b/sat/plugins/plugin_misc_text_commands.py @@ -327,7 +327,7 @@ class TextCommands(object): 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 --git a/sat/plugins/plugin_xep_0045.py b/sat/plugins/plugin_xep_0045.py index 2e99a01f..a06d7742 100644 --- a/sat/plugins/plugin_xep_0045.py +++ b/sat/plugins/plugin_xep_0045.py @@ -674,10 +674,19 @@ class XEP_0045(object): @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 @@ class XEP_0045(object): @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"]