summaryrefslogtreecommitdiff
path: root/src/text_buffer.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/text_buffer.py')
-rw-r--r--src/text_buffer.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/text_buffer.py b/src/text_buffer.py
index 832ce2f3..65da6975 100644
--- a/src/text_buffer.py
+++ b/src/text_buffer.py
@@ -21,10 +21,14 @@ Define the TextBuffer class
import logging
log = logging.getLogger(__name__)
+import collections
+
from datetime import datetime
import theme
from config import config
+Message = collections.namedtuple('Message', 'txt colorized nick_color time nickname color user')
+
class TextBuffer(object):
"""
This class just keep trace of messages, in a list with various
@@ -43,14 +47,8 @@ class TextBuffer(object):
def add_message(self, txt, time=None, nickname=None, colorized=False, nick_color=None):
color = theme.COLOR_NORMAL_TEXT if nickname is not None else theme.COLOR_INFORMATION_TEXT
nick_color = nick_color
- msg = {'txt': txt, 'colorized':colorized,
- 'time':time or datetime.now()}
- if nickname:
- msg['nickname'] = nickname
- if nick_color:
- msg['nick_color'] = nick_color
- if color:
- msg['color'] = color
+ msg = Message(txt=txt, colorized=colorized, nick_color=nick_color,
+ time=time or datetime.now(), nickname=nickname, color=color, user=None)
self.messages.append(msg)
while len(self.messages) > self.messages_nb_limit:
self.messages.pop(0)