comparison sat/plugins/plugin_xep_0045.py @ 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 813595f88612
comparison
equal deleted inserted replaced
3543:f19718296c20 3544:ae5f63e5ed2c
672 """join a new room 672 """join a new room
673 673
674 @command (all): JID 674 @command (all): JID
675 - JID: room to join (on the same service if full jid is not specified) 675 - JID: room to join (on the same service if full jid is not specified)
676 """ 676 """
677 if mess_data["unparsed"].strip(): 677 room_raw = mess_data["unparsed"].strip()
678 room_jid = self.text_cmds.getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) 678 if room_raw:
679 nick = (self.getRoomNick(client, room_jid) or 679 if self.isJoinedRoom(client, mess_data["to"]):
680 client.jid.user) 680 # we use the same service as the one from the room where the command has
681 # been entered if full jid is not entered
682 muc_service = mess_data["to"].host
683 nick = self.getRoomNick(client, mess_data["to"]) or client.jid.user
684 else:
685 # the command has been entered in a one2one conversation, so we use
686 # our server MUC service as default service
687 muc_service = client.muc_service or ""
688 nick = client.jid.user
689 room_jid = self.text_cmds.getRoomJID(room_raw, muc_service)
681 self.join(client, room_jid, nick, {}) 690 self.join(client, room_jid, nick, {})
682 691
683 return False 692 return False
684 693
685 def cmd_leave(self, client, mess_data): 694 def cmd_leave(self, client, mess_data):
686 """quit a room 695 """quit a room
687 696
688 @command (group): [ROOM_JID] 697 @command (group): [ROOM_JID]
689 - ROOM_JID: jid of the room to live (current room if not specified) 698 - ROOM_JID: jid of the room to live (current room if not specified)
690 """ 699 """
691 if mess_data["unparsed"].strip(): 700 room_raw = mess_data["unparsed"].strip()
692 room = self.text_cmds.getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) 701 if room_raw:
702 room = self.text_cmds.getRoomJID(room_raw, mess_data["to"].host)
693 else: 703 else:
694 room = mess_data["to"] 704 room = mess_data["to"]
695 705
696 self.leave(client, room) 706 self.leave(client, room)
697 707