quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)

This commit is contained in:
souliane 2014-08-23 20:26:04 +02:00
commit 3cee372b02

View file

@ -96,9 +96,17 @@ class QuickChat(object):
log.error (_("[INTERNAL] trying to set subject for a non group chat window"))
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
def afterHistoryPrint(self):
"""Refresh or scroll down the focus after the history is printed"""
pass
def historyPrint(self, size=20, profile='@NONE@'):
"""Print the initial history"""
log.debug (_("now we print history"))
"""Print the current history
@param size (int): number of messages
@param profile (str): %(doc_profile)s
"""
log.debug(_("now we print the history (%d messages)") % size)
def onHistory(history):
for line in history:
timestamp, from_jid, to_jid, message, _type, extra = line
@ -106,16 +114,17 @@ class QuickChat(object):
(self.type == 'one2one' and _type == 'groupchat')):
continue
self.printMessage(JID(from_jid), message, profile, timestamp)
self.afterHistoryPrint()
def onHistoryError(err):
log.error (_("Can't get history"))
log.error(_("Can't get history"))
if self.target.startswith(Const.PRIVATE_PREFIX):
target = unescapePrivate(self.target)
else:
target = self.target.bare
self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].bare, target, 20, profile=profile, callback=onHistory, errback=onHistoryError)
return self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].bare, target, size, profile=profile, callback=onHistory, errback=onHistoryError)
def _get_nick(self, jid):
"""Return nick of this jid when possible"""