Skip to content

Commit

Permalink
chanlogs: Do something about weird chars in filename
Browse files Browse the repository at this point in the history
This probably works, but tbh I'm just throwing it together and haven't
actually tested it. If it does work, it'll close sopel-irc#490.
  • Loading branch information
embolalia committed Feb 13, 2015
1 parent 9d1b309 commit 0606ee7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chanlogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from __future__ import unicode_literals
import os
import os.path
import re
import threading
import sys
from datetime import datetime
Expand All @@ -23,6 +24,8 @@
JOIN_TPL = "{datetime} *** {trigger.nick} has joined {trigger}"
PART_TPL = "{datetime} *** {trigger.nick} has left {trigger}"
QUIT_TPL = "{datetime} *** {trigger.nick} has quit IRC"
# According to Wikipedia
BAD_CHARS = re.compile(r'[\/?%*:|"<>. ]')


def configure(config):
Expand All @@ -48,6 +51,7 @@ def get_fpath(bot, trigger, channel=None):
basedir = os.path.expanduser(bot.config.chanlogs.dir)
channel = channel or trigger.sender
channel = channel.lstrip("#")
channel = BAD_CHARS.sub('__')

dt = datetime.utcnow()
if not bot.config.chanlogs.microseconds:
Expand Down

0 comments on commit 0606ee7

Please sign in to comment.