From 65c247399d4b5d8d78953e72cab89b7cf6b890fa Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 2 Apr 2014 01:04:53 +0200 Subject: Fix #2323 (implement XEP-0012 last activity) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TODO: check if this method of setting activity isn’t a bit heavy. --- src/core.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core.py b/src/core.py index caa3ae19..1ae34d3d 100644 --- a/src/core.py +++ b/src/core.py @@ -505,6 +505,7 @@ class Core(object): return res while self.running: + self.xmpp.plugin['xep_0012'].begin_idle(jid=self.xmpp.boundjid) big_char_list = [replace_key_with_bound(key)\ for key in self.read_keyboard()] # whether to refresh after ALL keys have been handled @@ -2297,7 +2298,7 @@ class Core(object): def command_last_activity(self, arg): """ - /activity + /last_activity """ def callback(iq): if iq['type'] != 'result': @@ -2325,7 +2326,14 @@ class Core(object): self.xmpp.plugin['xep_0012'].get_last_activity(jid, block=False, callback=callback) def completion_last_activity(self, the_input): - return the_input.new_completion([jid for jid in roster.jids()], 1, quotify=False) + """ + Completion for /last_activity + """ + n = the_input.get_argument_position(quoted=False) + if n >= 2: + return + comp = reduce(lambda x, y: x + [i.jid for i in y], (roster[jid].resources for jid in roster.jids() if len(roster[jid])), []) + return the_input.new_completion(sorted(comp), 1, '', quotify=False) def command_mood(self, arg): """ -- cgit v1.2.3