From 6781f67e80aa5ec86c84b49ef4526dcef9feceda Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 11 Nov 2012 16:01:53 +0100 Subject: =?UTF-8?q?Preload=20history=20into=20discussion=20windows=20(?= =?UTF-8?q?=C3=A0=20la=20mcabber)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - New option load_log defaulting to 200 to indicate the number of lines to be loaded - It’s still very raw, and the format of the message does not match the format of the normal room history, for example - Works in the Private chat, MUC, and Conversation tabs Thanks to labedz for the original code --- src/text_buffer.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/text_buffer.py') diff --git a/src/text_buffer.py b/src/text_buffer.py index 1dc042c6..f20c0cb9 100644 --- a/src/text_buffer.py +++ b/src/text_buffer.py @@ -35,7 +35,7 @@ class TextBuffer(object): def add_window(self, win): self.windows.append(win) - def make_message(self, txt, time, nickname, nick_color, history, user, identifier): + def make_message(self, txt, time, nickname, nick_color, history, user, identifier, str_time=None): time = time or datetime.now() if txt.startswith('/me '): if nick_color: @@ -47,15 +47,17 @@ class TextBuffer(object): # TODO: display the bg color too. txt = '\x19%(info_col)s}* \x19%(col)s}%(nick)s \x19%(info_col)s}%(msg)s' % {'info_col':get_theme().COLOR_ME_MESSAGE[0], 'col': color or 5, 'nick': nickname, 'msg': txt[4:]} nickname = None - msg = Message(txt='%s\x19o'%(txt.replace('\t', ' '),), nick_color=nick_color, - time=time, str_time=time.strftime("%Y-%m-%d %H:%M:%S")\ - if history else time.strftime("%H:%M:%S"),\ + msg = Message( + txt='%s\x19o'%(txt.replace('\t', ' '),), + nick_color=nick_color, + time=time, + str_time=(time.strftime("%Y-%m-%d %H:%M:%S") if history else time.strftime("%H:%M:%S")) if str_time is None else '', nickname=nickname, user=user, identifier=identifier) log.debug('Set message %s with %s.' % (identifier, msg)) return msg - def add_message(self, txt, time=None, nickname=None, nick_color=None, history=None, user=None, highlight=False, identifier=None): - msg = self.make_message(txt, time, nickname, nick_color, history, user, identifier) + def add_message(self, txt, time=None, nickname=None, nick_color=None, history=None, user=None, highlight=False, identifier=None, str_time=None): + msg = self.make_message(txt, time, nickname, nick_color, history, user, identifier, str_time) self.messages.append(msg) while len(self.messages) > self.messages_nb_limit: self.messages.pop(0) -- cgit v1.2.3