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/logger.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/logger.py')
-rw-r--r-- | src/logger.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/logger.py b/src/logger.py index 4858e116..8dfb25ea 100644 --- a/src/logger.py +++ b/src/logger.py @@ -63,6 +63,25 @@ class Logger(object): except IOError: return None + def get_logs(self, jid, nb=200): + """ + Get the log history for the given jid + """ + if nb <= 0: + return None + directory = os.path.join(DATA_HOME, 'logs') + try: + fd = open(os.path.join(directory, jid), 'r') + except: + return None + else: + if not fd: + return None + + logs = fd.readlines() + fd.close() + return logs[-nb:] + def log_message(self, jid, nick, msg): """ log the message in the appropriate jid's file |