Mercurial > libervia-backend
changeset 3544:ae5f63e5ed2c
plugin XEP-0045: fix `/join` text command
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 03 Jun 2021 17:59:41 +0200 |
parents | f19718296c20 |
children | 31cbcdd096a2 |
files | sat/plugins/plugin_misc_text_commands.py sat/plugins/plugin_xep_0045.py |
diffstat | 2 files changed, 17 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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"""
--- 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"]