Last active
December 16, 2015 19:29
-
-
Save awreece/5485419 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import string | |
regex_string = '.*(dark ?star|black ?hole|location|darkstar|php ?[1-4]|solution|core ?dump|spam ?carver|bitwise|get ?key|robomunication|format ?[1-2]|rop ?[1-4]|ever ?green|more ?evil|mildly ?evil|overflow ?[1-5]|clue|eval ?[1-5]|broken rsa|grep is your friend).*' | |
yell_string = "DO NOT DISCUSS PROBLEMS IN CHANNEL. If you need help, pm an op by doing '/query tylerni7' (or another op). Ops have an @ in front of their names." | |
good_guys = {'ajaska`': True, 'Feynman': True, 'rcombs': True, 'wizjany': True} | |
def good_guy(willie, trigger): | |
global good_guys | |
if trigger.admin: | |
good_guy = string.split(trigger.args[1], ' ', 1)[1] | |
good_guys[good_guy] = True | |
willie.reply("good guy " + good_guy + " doesn't need to be yelled at") | |
good_guy.commands=['good_guy'] | |
good_guy.thread = False | |
def list_good_guys(willie, trigger): | |
if trigger.admin: | |
willie.reply(" ".join(good_guys.keys()) + " are good guys") | |
list_good_guys.commands=['good_guys'] | |
list_good_guys.thread = False | |
def set_yell(willie, trigger): | |
global yell_string | |
if trigger.admin: | |
yell_string = string.split(trigger.args[1], ' ', 1)[1] | |
willie.reply("Yell set to " + yell_string) | |
set_yell.commands=['set_yell'] | |
set_yell.thread = False | |
def get_yell(willie, trigger): | |
global yell_string | |
if trigger.admin: | |
willie.reply("Yell is " + yell_string) | |
get_yell.commands=['get_yell'] | |
get_yell.thread = False | |
def yell_at_problem(willie, trigger): | |
if not trigger.admin and "broken" not in trigger.bytes and trigger.nick not in good_guys.keys() and "down" not in trigger.bytes: | |
willie.reply(yell_string) | |
yell_at_problem.rule = regex_string | |
yell_at_problem.rate = 60 | |
yell_at_problem.name = 'yell_at_problem' | |
yell_at_problem.thread = False | |
def topic_on_join(willie, trigger): | |
willie.write(['NOTICE', trigger.nick], trigger.nick + ": Read the topic - don't ask about questions in channel and read http://jeff.jones.be/technology/articles/how-to-ask-for-help-on-irc/") | |
topic_on_join.priority = 'low' | |
topic_on_join.event = 'JOIN' | |
topic_on_join.rule = '.*' | |
def get_regex(willie, trigger): | |
if trigger.admin: | |
willie.reply("Regex is currently " + regex_string) | |
get_regex.commands=['getregex'] | |
def set_regex(willie, trigger): | |
global regex_string | |
def ours(flist): | |
for f in flist: | |
if f.name == 'yell_at_problem': | |
return True | |
return False | |
if trigger.admin: | |
regex_string = string.split(trigger.args[1], ' ', 1)[1] | |
regexp = re.compile(regex_string, flags=re.IGNORECASE) | |
problem = filter(lambda (r, flist): ours(flist), | |
willie.commands['medium'].iteritems())[0] | |
willie.commands['medium'] = dict(filter(lambda (r, flist): not ours(flist), | |
willie.commands['medium'].iteritems())) | |
# Yeah, no clue why this works. I would expect [problem[1]] to be | |
# necessary. | |
willie.commands['medium'][regexp] = problem[1] | |
willie.reply("Yell regex set to " + regex_string) | |
set_regex.commands = ['setregex'] | |
set_regex.thread = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment