Skip to content

Instantly share code, notes, and snippets.

@rcombs
Forked from robxu9/yell_on_module.py
Last active December 16, 2015 19:29
Show Gist options
  • Save rcombs/5485491 to your computer and use it in GitHub Desktop.
Save rcombs/5485491 to your computer and use it in GitHub Desktop.
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]).*'
good_guys = {}
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 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.write([‘NOTICE’, trigger.nick], "DO NOT DISCUSS PROBLEMS IN CHANNEL. If you need help, pm an op by doing '/query tylerni7' (or another op). Ops have @ in front of their names.")
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], "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