Message timestamping is done when the message arrive, not when it is parsed

This commit is contained in:
Némunaire 2012-08-26 18:00:56 +02:00
parent 4892f8d9fa
commit f5166aca16
3 changed files with 6 additions and 6 deletions

2
bot.py
View file

@ -139,7 +139,7 @@ class Bot:
def receive_message(self, srv, raw_msg, private = False):
"""Queued the message for treatment"""
self.msg_queue.put_nowait((srv, raw_msg, private))
self.msg_queue.put_nowait((srv, raw_msg, datetime.now(), private))
# Launch a new thread if necessary
if self.msg_queue.qsize() > self.msg_thrd_size:

View file

@ -30,11 +30,11 @@ class Consumer(threading.Thread):
def run(self):
try:
while not self.stop:
(srv, raw, prvt) = self.context.msg_queue.get(True, 20)
(srv, raw, time, prvt) = self.context.msg_queue.get(True, 20)
# Create the message
# Create, parse and treat the message
try:
msg = Message(srv, raw, prvt)
msg = Message(srv, raw, time, prvt)
msg.treat(self.context.hooks)
except:
print ("\033[1;31mERROR:\033[0m occurred during the "

View file

@ -41,9 +41,9 @@ def save():
class Message:
def __init__ (self, srv, line, private = False):
def __init__ (self, srv, line, timestamp, private = False):
self.srv = srv
self.time = datetime.now ()
self.time = timestamp
self.channel = None
self.content = b''
self.ctcp = False