adding sieve.py, bot should work now

This commit is contained in:
Ryan Hitchman 2009-04-28 21:29:27 -06:00
parent 9234926201
commit ef210b828f
3 changed files with 41 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import os
import thread import thread
import codecs import codecs
import time import time
import re
import hook import hook
@ -25,6 +26,8 @@ formats = {'PRIVMSG': '<%(nick)s> %(msg)s',
ctcp_formats = {'ACTION': '* %(nick)s %(ctcpmsg)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): def get_log_filename(dir, network, chan):
return os.path.join(dir, 'log', gmtime('%Y'), network, 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_' + str(abs(n - leng))] = p
args['param_tail'] = ' '.join(args['paraml'][1:]) 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: if input.command == 'PRIVMSG' and input.msg.count('\x01') >= 2:
#ctcp #ctcp

9
plugins/profile.py Normal file
View File

@ -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())

28
plugins/sieve.py Normal file
View File

@ -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