From 3b55e00dd060e13f6f8bc09bd16977bf06483345 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 27 Jan 2020 23:26:54 +0000 Subject: move channel_log/__init__.py to channel_log.py --- modules/channel_log.py | 39 +++++++++++++++++++++++++++++++++++++++ modules/channel_log/__init__.py | 39 --------------------------------------- modules/channel_log/logs/.keep | 0 3 files changed, 39 insertions(+), 39 deletions(-) create mode 100644 modules/channel_log.py delete mode 100644 modules/channel_log/__init__.py delete mode 100644 modules/channel_log/logs/.keep (limited to 'modules') diff --git a/modules/channel_log.py b/modules/channel_log.py new file mode 100644 index 00000000..51ad7c04 --- /dev/null +++ b/modules/channel_log.py @@ -0,0 +1,39 @@ +#--depends-on config +#--depends-on format_activity + +import datetime, os.path +from src import ModuleManager, utils + +ROOT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) +LOGS_DIRECTORY = os.path.join(ROOT_DIRECTORY, "logs") + +@utils.export("channelset", utils.BoolSetting("log", + "Enable/disable channel logging")) +class Module(ModuleManager.BaseModule): + def _file(self, server_name, channel_name): + return self.data_directory("%s/%s.log" % (server_name, channel_name)) + def _log(self, event, channel): + if channel.get_setting("log", True): + with open(self._file(str(event["server"]), str(channel)), "a") as log: + timestamp = datetime.datetime.now().strftime("%x %X") + log.write("%s %s\n" % (timestamp, event["line"])) + + @utils.hook("formatted.message.channel") + @utils.hook("formatted.notice.channel") + @utils.hook("formatted.join") + @utils.hook("formatted.part") + @utils.hook("formatted.nick") + @utils.hook("formatted.invite") + @utils.hook("formatted.mode.channel") + @utils.hook("formatted.topic") + @utils.hook("formatted.topic-timestamp") + @utils.hook("formatted.kick") + @utils.hook("formatted.quit") + @utils.hook("formatted.rename") + @utils.hook("formatted.chghost") + def on_formatted(self, event): + if event["channel"]: + self._log(event, event["channel"]) + elif event["user"]: + for channel in event["user"].channels: + self._log(event, channel) diff --git a/modules/channel_log/__init__.py b/modules/channel_log/__init__.py deleted file mode 100644 index 51ad7c04..00000000 --- a/modules/channel_log/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -#--depends-on config -#--depends-on format_activity - -import datetime, os.path -from src import ModuleManager, utils - -ROOT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) -LOGS_DIRECTORY = os.path.join(ROOT_DIRECTORY, "logs") - -@utils.export("channelset", utils.BoolSetting("log", - "Enable/disable channel logging")) -class Module(ModuleManager.BaseModule): - def _file(self, server_name, channel_name): - return self.data_directory("%s/%s.log" % (server_name, channel_name)) - def _log(self, event, channel): - if channel.get_setting("log", True): - with open(self._file(str(event["server"]), str(channel)), "a") as log: - timestamp = datetime.datetime.now().strftime("%x %X") - log.write("%s %s\n" % (timestamp, event["line"])) - - @utils.hook("formatted.message.channel") - @utils.hook("formatted.notice.channel") - @utils.hook("formatted.join") - @utils.hook("formatted.part") - @utils.hook("formatted.nick") - @utils.hook("formatted.invite") - @utils.hook("formatted.mode.channel") - @utils.hook("formatted.topic") - @utils.hook("formatted.topic-timestamp") - @utils.hook("formatted.kick") - @utils.hook("formatted.quit") - @utils.hook("formatted.rename") - @utils.hook("formatted.chghost") - def on_formatted(self, event): - if event["channel"]: - self._log(event, event["channel"]) - elif event["user"]: - for channel in event["user"].channels: - self._log(event, channel) diff --git a/modules/channel_log/logs/.keep b/modules/channel_log/logs/.keep deleted file mode 100644 index e69de29b..00000000 -- cgit v1.3.1-10-gc9f91