Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@core.command("crashnow")
def crash_immediately():
"Crash now!"
raise TypeError("You should never call this!")
@command(aliases="dm")
def demotivate(channel, rest):
"Demotivate someone"
if rest:
r = rest.strip()
else:
r = channel
karma.Karma.store.change(r, -1)
return "you're doing horrible work, %s!" % r
@command(aliases=("slap", "ts"))
def troutslap(rest):
"Slap some(one|thing) with a fish"
slapee = rest
karma.Karma.store.change(slapee, -1)
return "/me slaps %s around a bit with a large trout" % slapee
@command(aliases=("urb", 'ud', 'urbandictionary', 'urbandefine', 'urbandef', 'urbdef'))
def urbandict(rest):
"Define a word with Urban Dictionary"
word = rest.strip()
definition = util.urban_lookup(word)
if not definition:
return "Arg! I didn't find a definition for that."
return 'Urban Dictionary says {word}: {definition}'.format(**locals())
@command()
def insult(rest):
"Generate a random insult from datahamster"
# not supplying any style will automatically redirect to a random
url = 'http://autoinsult.datahamster.com/'
ins_type = random.randrange(4)
ins_url = url + "?style={ins_type}".format(**locals())
insre = re.compile('<div id="insult" class="insult">(.*?)</div>')
resp = requests.get(ins_url)
resp.raise_for_status()
insult = insre.search(resp.text).group(1)
if not insult:
return
if rest:
insultee = rest.strip()
karma.Karma.store.change(insultee, -1)
if ins_type in (0, 2):
@command()
def blame(channel, rest, nick):
"Pass the buck!"
if rest:
blamee = rest
else:
blamee = channel
karma.Karma.store.change(nick, -1)
if random.randint(1, 10) == 1:
yield "/me jumps atop the chair and points back at %s." % nick
yield (
"stop blaming the world for your problems, you bitter, "
"two-faced sissified monkey!"
)
else:
yield (
"I blame %s for everything! it's your fault! "
@command(aliases=("bottom",))
def bottom10(rest):
"""
Return the bottom n (default 10) lowest entities by Karmic value.
Use negative numbers for the bottom N.
"""
if rest:
topn = -int(rest)
else:
topn = -10
selection = Karma.store.list(topn)
res = ' '.join('(%s: %s)' % (', '.join(n), k) for n, k in selection)
return res
@command()
def fml(rest):
"A SFW version of fml."
return "indeed"
@command()
def calc(rest):
"Perform a basic calculation"
mo = calc_exp.match(rest)
if mo:
try:
return str(eval(rest))
except Exception:
return "eval failed... check your syntax"
else:
return "misformatted arithmetic!"