summaryrefslogtreecommitdiff
path: root/poezio/core
diff options
context:
space:
mode:
Diffstat (limited to 'poezio/core')
-rw-r--r--poezio/core/commands.py29
-rw-r--r--poezio/core/core.py8
2 files changed, 37 insertions, 0 deletions
diff --git a/poezio/core/commands.py b/poezio/core/commands.py
index 4dbb5611..6cf398ff 100644
--- a/poezio/core/commands.py
+++ b/poezio/core/commands.py
@@ -508,6 +508,35 @@ class CommandCore:
self.core.bookmarks.save(self.core.xmpp, callback=cb)
else:
self.core.information('No bookmark to remove', 'Info')
+
+ @command_args_parser.quoted(1)
+ def command_add(self, args):
+ """
+ Add the specified JID to the roster, and automatically
+ accept the reverse subscription
+ """
+ if args is None:
+ jid = self.core.tabs.current_tab.name
+ if jid is 'Roster' or 'muc' in jid:
+ self.core.information('No JID specified', 'Error')
+ return
+ else:
+ 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')
+ return
+ jid = safeJID(safeJID(args[0]).bare)
+ if not str(jid):
+ self.core.information(
+ 'The provided JID (%s) is not valid' % (args[0], ), 'Error')
+ return
+ 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')
@command_args_parser.ignored
def command_reconnect(self):
diff --git a/poezio/core/core.py b/poezio/core/core.py
index 6bb19d16..51c304fa 100644
--- a/poezio/core/core.py
+++ b/poezio/core/core.py
@@ -1759,6 +1759,14 @@ class Core:
shortdesc="Bookmark a room online.",
completion=self.completion.bookmark)
self.register_command(
+ 'add',
+ self.command.command_add,
+ usage='<jid>',
+ desc='Add the specified 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.register_command(
'reconnect',
self.command.command_reconnect,
usage="[reconnect]",