diff --git a/plugins/log.py b/plugins/log.py index 829f93b..2bbb7b1 100644 --- a/plugins/log.py +++ b/plugins/log.py @@ -6,6 +6,7 @@ import os import thread import codecs import time +import re import hook @@ -25,6 +26,8 @@ formats = {'PRIVMSG': '<%(nick)s> %(msg)s', ctcp_formats = {'ACTION': '* %(nick)s %(ctcpmsg)s'} +irc_color_re = re.compile(r'(\x03(\d+,\d+|\d)|[\x0f\x02\x16\x1f])') + def get_log_filename(dir, network, chan): return os.path.join(dir, 'log', gmtime('%Y'), network, @@ -44,6 +47,7 @@ def beautify(input): args['param_' + str(abs(n - leng))] = p args['param_tail'] = ' '.join(args['paraml'][1:]) + args['msg'] = irc_color_re.sub('', args['msg']) if input.command == 'PRIVMSG' and input.msg.count('\x01') >= 2: #ctcp diff --git a/plugins/profile.py b/plugins/profile.py new file mode 100644 index 0000000..0509f3d --- /dev/null +++ b/plugins/profile.py @@ -0,0 +1,9 @@ +# for crusty old rotor + +import hook + + +@hook.command +def profile(inp): + return 'http://forums.somethingawful.com/member.php?action=getinfo' + \ + '&username=' + '+'.join(inp.split()) diff --git a/plugins/sieve.py b/plugins/sieve.py new file mode 100644 index 0000000..97e3f4e --- /dev/null +++ b/plugins/sieve.py @@ -0,0 +1,28 @@ +import re + +import hook + + +@hook.sieve +def sieve_suite(bot, input, func, args): + events = args.get('events', ['PRIVMSG']) + + if input.command not in events and events != '*': + return None + + if input.nick.lower()[-3:] == 'bot' and args.get('ignorebots', True): + return None + + hook = args.get('hook', r'(.*)') + + if args.get('prefix', True): + hook = (r'^(?:[.!]|' if input.chan != input.nick else r'^(?:[.!]?|') \ + + bot.nick +r'[:,]*\s*)' + hook + + input.re = re.match(hook, input.msg, flags=re.I) + if input.re is None: + return None + + input.inp = ' '.join(input.re.groups()) + + return input