diff options
author | mathieui <mathieui@mathieui.net> | 2012-11-11 16:01:53 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2012-11-11 16:01:53 +0100 |
commit | 6781f67e80aa5ec86c84b49ef4526dcef9feceda (patch) | |
tree | 03b86fbcf9cc34fb8412558fec4e3c19c78a268d /src/tabs.py | |
parent | 844392a69aad39b37281f212b0a55c8a611575ac (diff) | |
download | poezio-6781f67e80aa5ec86c84b49ef4526dcef9feceda.tar.gz poezio-6781f67e80aa5ec86c84b49ef4526dcef9feceda.tar.bz2 poezio-6781f67e80aa5ec86c84b49ef4526dcef9feceda.tar.xz poezio-6781f67e80aa5ec86c84b49ef4526dcef9feceda.zip |
Preload history into discussion windows (à la mcabber)
- 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 <github@labedz.org> for the original code
Diffstat (limited to 'src/tabs.py')
-rw-r--r-- | src/tabs.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/tabs.py b/src/tabs.py index 41bb511e..d98382d9 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -389,8 +389,9 @@ class ChatTab(Tab): """ plugin_commands = {} plugin_keys = {} - def __init__(self): + def __init__(self, jid=''): Tab.__init__(self) + self.name = jid self._text_buffer = TextBuffer() self.remote_wants_chatstates = None # change this to True or False when # we know that the remote user wants chatstates, or not. @@ -421,6 +422,24 @@ class ChatTab(Tab): self.update_commands() self.update_keys() + # Get the logs + log_nb = config.get('load_log', 200) + + if isinstance(self, PrivateTab): + logs = logger.get_logs(safeJID(self.get_name()).full.replace('/', '\\'), log_nb) + else: + logs = logger.get_logs(safeJID(self.get_name()).bare, log_nb) + if logs: + for log_line in logs: + log_line = '\x19%s}%s' % (get_theme().COLOR_INFORMATION_TEXT[0], log_line) + self._text_buffer.add_message( + txt=log_line.strip(), + time='', + nickname='', + user='', + str_time='' + ) + def last_words_completion(self): """ Complete the input with words recently said @@ -617,7 +636,7 @@ class MucTab(ChatTab): plugin_keys = {} def __init__(self, jid, nick): self.joined = False - ChatTab.__init__(self) + ChatTab.__init__(self, jid) self.own_nick = nick self.name = jid self.users = [] @@ -1611,7 +1630,7 @@ class PrivateTab(ChatTab): plugin_commands = {} plugin_keys = {} def __init__(self, name, nick): - ChatTab.__init__(self) + ChatTab.__init__(self, name) self.own_nick = nick self.name = name self.text_win = windows.TextWin() @@ -2669,7 +2688,7 @@ class ConversationTab(ChatTab): additional_informations = {} message_type = 'chat' def __init__(self, jid): - ChatTab.__init__(self) + ChatTab.__init__(self, jid) self.state = 'normal' self.name = jid # a conversation tab is linked to one specific full jid OR bare jid self.text_win = windows.TextWin() |