From 1a2309e4fccf39a5d5d7e81b63bb64d42e6e7a7b Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 2 May 2019 10:24:01 +0100 Subject: [PATCH] add 'print-motd' bot setting, to enable/disable printing motd to log --- modules/print_activity.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/print_activity.py b/modules/print_activity.py index 7f0d3777..0aaf583a 100644 --- a/modules/print_activity.py +++ b/modules/print_activity.py @@ -1,7 +1,14 @@ import datetime from src import EventManager, ModuleManager, utils +@utils.export("botset", {"setting": "print-motd", + "help": "Set whether I print /motd", "validate": utils.bool_or_none}) class Module(ModuleManager.BaseModule): + def _print(self, event): + self.bot.log.info("%s%s | %s", [ + str(event["server"]), event["context"] or "", + utils.irc.parse_format(event["line"])]) + @utils.hook("formatted.message.channel") @utils.hook("formatted.notice.channel") @utils.hook("formatted.notice.private") @@ -16,8 +23,10 @@ class Module(ModuleManager.BaseModule): @utils.hook("formatted.kick") @utils.hook("formatted.quit") @utils.hook("formatted.rename") - @utils.hook("formatted.motd") def formatted(self, event): - self.bot.log.info("%s%s | %s", [ - str(event["server"]), event["context"] or "", - utils.irc.parse_format(event["line"])]) + self._print(event) + + @utils.hook("formatted.motd") + def motd(self, event): + if self.bot.get_setting("print-motd", True): + self._print(event)