summaryrefslogtreecommitdiff
path: root/poezio/core/commands.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-05-10 00:10:46 +0200
committermathieui <mathieui@mathieui.net>2020-05-10 00:11:23 +0200
commita1c8efdfb2f28976aaa653e5fc1e695b943bb739 (patch)
tree10996f59972b2be47eae9ad4da257961c72f7429 /poezio/core/commands.py
parente03fb0b3ce41de208e4b52ee1224a080cfc5c6f5 (diff)
downloadpoezio-a1c8efdfb2f28976aaa653e5fc1e695b943bb739.tar.gz
poezio-a1c8efdfb2f28976aaa653e5fc1e695b943bb739.tar.bz2
poezio-a1c8efdfb2f28976aaa653e5fc1e695b943bb739.tar.xz
poezio-a1c8efdfb2f28976aaa653e5fc1e695b943bb739.zip
Move /deny and /remove to global scope as well
Diffstat (limited to 'poezio/core/commands.py')
-rw-r--r--poezio/core/commands.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/poezio/core/commands.py b/poezio/core/commands.py
index 60bcc7b0..6bf1d338 100644
--- a/poezio/core/commands.py
+++ b/poezio/core/commands.py
@@ -585,6 +585,56 @@ class CommandCore:
roster.modified()
self.core.information('%s was added to the roster' % jid, 'Roster')
+ @deny_anonymous
+ @command_args_parser.quoted(0, 1)
+ def deny(self, args):
+ """
+ /deny [jid]
+ Denies a JID from our roster
+ """
+ jid = None
+ if not args:
+ tab = self.core.tabs.current_tab
+ if isinstance(tab, tabs.RosterInfoTab):
+ item = tab.roster_win.selected_row
+ if isinstance(item, Contact):
+ jid = item.bare_jid
+ else:
+ jid = safeJID(args[0]).bare
+ if jid not in [jid for jid in roster.jids()]:
+ jid = None
+ if jid is None:
+ self.core.information('No subscription to deny', 'Warning')
+ return
+
+ contact = roster[jid]
+ if contact:
+ contact.unauthorize()
+ self.core.information('Subscription to %s was revoked' % jid,
+ 'Roster')
+
+ @deny_anonymous
+ @command_args_parser.quoted(0, 1)
+ def remove(self, args):
+ """
+ Remove the specified JID from the roster. i.e.: unsubscribe
+ from its presence, and cancel its subscription to our.
+ """
+ jid = None
+ if args:
+ jid = safeJID(args[0]).bare
+ else:
+ tab = self.core.tabs.current_tab
+ if isinstance(tab, tabs.RosterInfoTab):
+ item = tab.roster_win.selected_row
+ if isinstance(item, Contact):
+ jid = item.bare_jid
+ if jid is None:
+ self.core.information('No roster item to remove', 'Error')
+ return
+ roster.remove(jid)
+ del roster[jid]
+
@command_args_parser.ignored
def command_reconnect(self):
"""