summaryrefslogtreecommitdiff
path: root/poezio/tabs/conversationtab.py
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2017-05-15 23:09:27 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2017-05-15 23:09:27 +0100
commit83e28a2be874ac024ad68b767744ae73af229195 (patch)
tree33ef7e54ec9cdec1111b3c6032c2a253a1f2d16f /poezio/tabs/conversationtab.py
parentc66c5a6e27782023dac7ccff71038e880be0ad1c (diff)
downloadpoezio-83e28a2be874ac024ad68b767744ae73af229195.tar.gz
poezio-83e28a2be874ac024ad68b767744ae73af229195.tar.bz2
poezio-83e28a2be874ac024ad68b767744ae73af229195.tar.xz
poezio-83e28a2be874ac024ad68b767744ae73af229195.zip
Add /add in conversation tabs.
This is a quick shortcut to add someone to your roster when talking with them. Fixes #3313. Also fixes typos.
Diffstat (limited to 'poezio/tabs/conversationtab.py')
-rw-r--r--poezio/tabs/conversationtab.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/poezio/tabs/conversationtab.py b/poezio/tabs/conversationtab.py
index 5c309672..8da8f5ca 100644
--- a/poezio/tabs/conversationtab.py
+++ b/poezio/tabs/conversationtab.py
@@ -61,6 +61,11 @@ class ConversationTab(OneToOneTab):
desc='Get the last activity of the given or the current contact.',
shortdesc='Get the activity.',
completion=self.core.completion.last_activity)
+ self.register_command('add', self.command_add,
+ desc='Add the current JID to your roster, ask them to'
+ ' allow you to see his presence, and allow them to'
+ ' see your presence.',
+ shortdesc='Add a user to your roster.')
self.resize()
self.update_commands()
self.update_keys()
@@ -224,6 +229,19 @@ class ConversationTab(OneToOneTab):
fixes.get_version(self.core.xmpp, jid,
callback=callback)
+ @command_args_parser.ignored
+ def command_add(self):
+ """
+ Add the current JID to the roster, and automatically
+ accept the reverse subscription
+ """
+ jid = self.general_jid
+ if jid in roster and roster[jid].subscription in ('to', 'both'):
+ return self.core.information('Already subscribed.', 'Roster')
+ roster.add(jid)
+ roster.modified()
+ self.core.information('%s was added to the roster' % jid, 'Roster')
+
def resize(self):
self.need_resize = False
if self.size.tab_degrade_y: