diff options
Diffstat (limited to 'poezio/core')
-rw-r--r-- | poezio/core/commands.py | 14 | ||||
-rw-r--r-- | poezio/core/core.py | 20 |
2 files changed, 10 insertions, 24 deletions
diff --git a/poezio/core/commands.py b/poezio/core/commands.py index 5b990091..e785a93b 100644 --- a/poezio/core/commands.py +++ b/poezio/core/commands.py @@ -335,7 +335,7 @@ class CommandCore: if room.find('@') == -1 and not server_root: tab = self.core.tabs.current_tab if isinstance(tab, tabs.MucTab): - if tab.name.full.find('@') != -1: + if tab.name.find('@') != -1: domain = safeJID(tab.name).domain room += '@%s' % domain return (room, set_nick) @@ -369,8 +369,7 @@ class CommandCore: # New tab if tab is None: tab = self.core.open_new_room(room, nick, password=password) - if tab is not None: - tab.join() + tab.join() else: self.core.focus_tab(tab) if tab.own_nick == nick and tab.joined: @@ -1024,17 +1023,14 @@ class CommandCore: """ if args is None: return self.help('message') - try: - jid = JID(args[0]) - except InvalidJID: - return self.core.information('Invalid JID.', 'Error') - if not jid.bare: + jid = safeJID(args[0]) + if not jid.user and not jid.domain and not jid.resource: return self.core.information('Invalid JID.', 'Error') tab = self.core.get_conversation_by_jid( jid.full, False, fallback_barejid=False) muc = self.core.tabs.by_name_and_class(jid.bare, tabs.MucTab) if not tab and not muc: - tab = self.core.open_conversation_window(jid, focus=True) + tab = self.core.open_conversation_window(jid.full, focus=True) elif muc: if jid.resource: tab = self.core.tabs.by_name_and_class(jid.full, diff --git a/poezio/core/core.py b/poezio/core/core.py index 5e3e912b..7553c57d 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -1164,7 +1164,7 @@ class Core: provided, we open a StaticConversationTab, else a DynamicConversationTab """ - if jid.resource: + if safeJID(jid).resource: new_tab = tabs.StaticConversationTab(self, jid) else: new_tab = tabs.DynamicConversationTab(self, jid) @@ -1179,12 +1179,7 @@ class Core: """ Open a Private conversation in a MUC and focus if needed. """ - try: - complete_jid_str = room_name + '/' + user_nick - complete_jid = JID(complete_jid_str) - except InvalidJID: - self.information('Invalid XMPP address %r for chat tab.', complete_jid_str) - return None + complete_jid = room_name + '/' + user_nick # if the room exists, focus it and return for tab in self.get_tabs(tabs.PrivateTab): if tab.name == complete_jid: @@ -1210,15 +1205,10 @@ class Core: nick: str, *, password: Optional[str] = None, - focus=True) -> Optional[tabs.MucTab]: + focus=True) -> tabs.MucTab: """ Open a new tab.MucTab containing a muc Room, using the specified nick """ - try: - room = JID(room) - except InvalidJID: - self.information('Invalid XMPP address %r for chat tab.', room) - return None new_tab = tabs.MucTab(self, room, nick, password=password) self.add_tab(new_tab, focus) self.refresh_window() @@ -1277,7 +1267,7 @@ class Core: if reason is None: reason = '\x195}You left the room\x193}' for tab in self.get_tabs(tabs.PrivateTab): - if tab.name.full.startswith(room_name): + if tab.name.startswith(room_name): tab.deactivate(reason=reason) def enable_private_tabs(self, room_name: str, @@ -1288,7 +1278,7 @@ class Core: if reason is None: reason = '\x195}You joined the room\x193}' for tab in self.get_tabs(tabs.PrivateTab): - if tab.name.full.startswith(room_name): + if tab.name.startswith(room_name): tab.activate(reason=reason) def on_user_changed_status_in_private(self, jid: JID, status: str) -> None: |