From 3e574f3c52f7be7435f33fe17c02d40c3e581d7f Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 17 Jan 2020 15:58:08 +0000 Subject: [PATCH] add BufferLine.timestamp (`datetime.datetime` object) --- src/IRCBuffer.py | 7 +++++-- src/core_modules/line_handler/message.py | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/IRCBuffer.py b/src/IRCBuffer.py index 8ff21d4c..bf3af5df 100644 --- a/src/IRCBuffer.py +++ b/src/IRCBuffer.py @@ -1,4 +1,4 @@ -import collections, dataclasses, re, typing +import collections, dataclasses, datetime, re, typing from src import IRCBot, IRCServer, utils MAX_LINES = 64 @@ -6,15 +6,18 @@ MAX_LINES = 64 @dataclasses.dataclass class BufferLine(object): id: str + timestamp: datetime.datetime sender: str message: str action: bool tags: dict from_self: bool method: str + + deleted: bool=False + notes: typing.Dict[str, str] = dataclasses.field( default_factory=dict) - deleted: bool=False class BufferLineMatch(object): def __init__(self, line: BufferLine, match: str): diff --git a/src/core_modules/line_handler/message.py b/src/core_modules/line_handler/message.py index 8b231ede..8db74461 100644 --- a/src/core_modules/line_handler/message.py +++ b/src/core_modules/line_handler/message.py @@ -101,8 +101,9 @@ def message(events, event): buffer_line = None if message: - buffer_line = IRCBuffer.BufferLine(message_id, user.nickname, message, - action, event["line"].tags, from_self, event["line"].command) + buffer_line = IRCBuffer.BufferLine(message_id, utils.datetime.utcnow(), + user.nickname, message, action, event["line"].tags, from_self, + event["line"].command) buffer_obj = target_obj if is_channel: