Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def karma(nick, rest):
"Return or change the karma value for some(one|thing)"
karmee = rest.strip('++').strip('--').strip('~~')
if '++' in rest:
Karma.store.change(karmee, 1)
elif '--' in rest:
Karma.store.change(karmee, -1)
elif '~~' in rest:
change = random.choice([-1, 0, 1])
Karma.store.change(karmee, change)
if change == 1:
return "%s karma++" % karmee
elif change == 0:
return "%s karma shall remain the same" % karmee
elif change == -1:
return "%s karma--" % karmee
elif '==' in rest:
t1, t2 = rest.split('==')
try:
Karma.store.link(t1, t2)
except SameName:
Karma.store.change(nick, -1)
return "Don't try to link a name to itself!"
def disembowel(rest):
"Disembowel some(one|thing)!"
if rest:
stabee = rest
karma.Karma.store.change(stabee, -1)
else:
stabee = "someone nearby"
return (
"/me takes %s, brings them down to the basement, ties them to a "
"leaky pipe, and once bored of playing with them mercifully "
"ritually disembowels them..." % stabee
)
def cheer(rest):
"Cheer for something"
if rest:
karma.Karma.store.change(rest, 1)
return "/me cheers for %s!" % rest
karma.Karma.store.change('the day', 1)
return "/me cheers!"
def bitchingisuseless(channel, rest):
"It really is, ya know..."
rest = rest.strip()
if rest:
karma.Karma.store.change(rest, -1)
else:
karma.Karma.store.change(channel, -1)
rest = "foo'"
advice = 'Quiet bitching is useless, %s. Do something about it.' % rest
return advice
def emer_comp(rest):
"Return a random compliment from http://emergencycompliment.com/"
comps = util.load_emergency_compliments()
compliment = random.choice(comps)
if rest:
complimentee = rest.strip()
karma.Karma.store.change(complimentee, 1)
return "%s: %s" % (complimentee, compliment)
return compliment
def fight(nick, rest):
"Pit two sworn enemies against each other (separate with 'vs.')"
if rest:
vtype = random.choice(phrases.fight_victories)
fdesc = random.choice(phrases.fight_descriptions)
# valid separators are vs., v., and vs
pattern = re.compile('(.*) (?:vs[.]?|v[.]) (.*)')
matcher = pattern.match(rest)
if not matcher:
karma.Karma.store.change(nick.lower(), -1)
args = (vtype, nick, fdesc)
return "/me %s %s in %s for bad protocol." % args
contenders = [c.strip() for c in matcher.groups()]
random.shuffle(contenders)
winner, loser = contenders
karma.Karma.store.change(winner, 1)
karma.Karma.store.change(loser, -1)
return "%s %s %s in %s." % (winner, vtype, loser, fdesc)
def imotivate(channel, rest):
'Ironically "Motivate" someone'
if rest:
r = rest.strip()
karma.Karma.store.change(r, -1)
else:
r = channel
return '''you're "doing" "good" "work", %s!''' % r
def fight(nick, rest):
"Pit two sworn enemies against each other (separate with 'vs.')"
if rest:
vtype = random.choice(phrases.fight_victories)
fdesc = random.choice(phrases.fight_descriptions)
# valid separators are vs., v., and vs
pattern = re.compile('(.*) (?:vs[.]?|v[.]) (.*)')
matcher = pattern.match(rest)
if not matcher:
karma.Karma.store.change(nick.lower(), -1)
args = (vtype, nick, fdesc)
return "/me %s %s in %s for bad protocol." % args
contenders = [c.strip() for c in matcher.groups()]
random.shuffle(contenders)
winner, loser = contenders
karma.Karma.store.change(winner, 1)
karma.Karma.store.change(loser, -1)
return "%s %s %s in %s." % (winner, vtype, loser, fdesc)