track, display timestamp of history

This commit is contained in:
Brian S. Stephan 2021-05-05 08:08:47 -05:00
parent e43807fb27
commit def5964658
1 changed files with 4 additions and 2 deletions

View File

@ -1,5 +1,6 @@
"""Monitor and playback IRC stuff."""
import logging
from datetime import datetime
import irc.client
@ -47,10 +48,11 @@ class History(Plugin):
what = event.arguments[0]
where = event.target
who = irc.client.NickMask(event.source).nick
when = datetime.now()
logger.debug("tracking message for %s: (%s,%s)", where, who, what)
history = self.channel_history.setdefault(where, [])
history.append((who, what))
history.append((when.isoformat(), who, what))
logger.debug("history for %s: %s", where, history)
# for when we maybe don't see a join, if they talked in the channel, add them to it
@ -107,7 +109,7 @@ class History(Plugin):
def _send_history(self, who, history):
"""Reply to who with missed history."""
for line in history:
self.bot.privmsg(who, f"<{line[0]}> {line[1]}")
self.bot.privmsg(who, f"[{line[0]}] <{line[1]}> {line[2]}")
def _add_channel_leave_point(self, where, who):
"""Note that the given who left the channel at the current history point."""