Print a topic's set at time when we receive a 333 (print_activity.py)

This commit is contained in:
jesopo 2019-01-02 13:39:49 +00:00
parent 3d60d59510
commit cb3e40a462

View file

@ -1,6 +1,8 @@
import datetime import datetime
from src import EventManager, ModuleManager, utils from src import EventManager, ModuleManager, utils
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
class Module(ModuleManager.BaseModule): class Module(ModuleManager.BaseModule):
def print_line(self, event, line, channel=None): def print_line(self, event, line, channel=None):
timestamp = datetime.datetime.now().isoformat() timestamp = datetime.datetime.now().isoformat()
@ -106,6 +108,11 @@ class Module(ModuleManager.BaseModule):
self._on_topic(event, event["setter"], "set", self._on_topic(event, event["setter"], "set",
event["channel"].topic, event["channel"]) event["channel"].topic, event["channel"])
unix_dt = datetime.datetime.utcfromtimestamp(event["set_at"])
dt = datetime.datetime.strftime(unix_dt, DATETIME_FORMAT)
self.print_line(event, "topic set at %s" % dt,
channel=event["channel"].name)
@utils.hook("received.mode.channel") @utils.hook("received.mode.channel")
def mode(self, event): def mode(self, event):
args = " ".join(event["mode_args"]) args = " ".join(event["mode_args"])