Message timestamping is done when the message arrive, not when it is parsed
This commit is contained in:
parent
4892f8d9fa
commit
f5166aca16
3 changed files with 6 additions and 6 deletions
2
bot.py
2
bot.py
|
@ -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:
|
||||
|
|
|
@ -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 "
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue