replace "/" in channel logfile names with ","
This commit is contained in:
parent
90c8805cb5
commit
53c6cc8538
1 changed files with 7 additions and 1 deletions
|
@ -17,7 +17,13 @@ class Module(ModuleManager.BaseModule):
|
||||||
server.get_setting("channel-log",
|
server.get_setting("channel-log",
|
||||||
self.bot.get_setting("channel-log", False)))
|
self.bot.get_setting("channel-log", False)))
|
||||||
def _file(self, server_name, channel_name):
|
def _file(self, server_name, channel_name):
|
||||||
return self.data_directory("%s/%s.log" % (server_name, channel_name))
|
# if a channel name has os.path.sep (e.g. "/") in it, the channel's log
|
||||||
|
# file will create a subdirectory.
|
||||||
|
#
|
||||||
|
# to avoid this, we'll replace os.path.sep with "," (0x2C) as it is
|
||||||
|
# forbidden in channel names.
|
||||||
|
sanitised_name = channel_name.replace(os.path.sep, ",")
|
||||||
|
return self.data_directory("%s/%s.log" % (server_name, sanitised_name))
|
||||||
def _log(self, server, channel, line):
|
def _log(self, server, channel, line):
|
||||||
if self._enabled(server, channel):
|
if self._enabled(server, channel):
|
||||||
with open(self._file(str(server), str(channel)), "a") as log:
|
with open(self._file(str(server), str(channel)), "a") as log:
|
||||||
|
|
Loading…
Reference in a new issue