From 0667ac8c5f441facf2c94a1fe9ad339c8d840bea Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 20 Feb 2020 14:56:04 +0000 Subject: add option to encrypt channel_log log files line-by-line --- modules/channel_log.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/channel_log.py b/modules/channel_log.py index 8344e9cd..a15d51f7 100644 --- a/modules/channel_log.py +++ b/modules/channel_log.py @@ -26,10 +26,16 @@ class Module(ModuleManager.BaseModule): return self.data_directory("%s/%s.log" % (server_name, sanitised_name)) def _log(self, server, channel, line): if self._enabled(server, channel): - with open(self._file(str(server), str(channel)), "a") as log: - timestamp = utils.datetime.format.datetime_human( - datetime.datetime.now()) - log.write("%s %s\n" % (timestamp, line)) + timestamp = utils.datetime.format.datetime_human( + datetime.datetime.now()) + log_line = "%s %s" % (timestamp, line) + + if "log-key" in self.bot.config: + log_line = "\x02%s" % utils.security.a_encrypt( + self.bot.config["log-key"], log_line) + + with open(self._file(str(server), str(channel)), "a") as log_file: + log_file.write("%s\n" % log_line) @utils.hook("formatted.message.channel") @utils.hook("formatted.notice.channel") -- cgit v1.3.1-10-gc9f91