h/plugins/printerfact.py

20 lines
606 B
Python
Raw Permalink Normal View History

2015-11-03 01:18:44 +00:00
from util import hook
import requests, re, random
regex = re.compile(re.escape("cat"), re.IGNORECASE)
kittenrex = re.compile(re.escape("kitten"), re.IGNORECASE)
2015-11-09 20:38:53 +00:00
preggorex = re.compile(re.escape("pregmant"), re.IGNORECASE)
2015-11-03 01:18:44 +00:00
@hook.regex("PHP sadness$")
def php_fact(inp):
return "http://phpsadness.com/sad/" + str(random.randint(0,53))
2015-11-09 20:38:53 +00:00
@hook.regex("^printer fact$")
2015-11-05 20:43:12 +00:00
@hook.command
2015-11-03 01:18:44 +00:00
def printerfact(inp, say=None):
r = requests.get('https://catfacts-api.appspot.com/api/facts?number=1')
fact = r.json()['facts'][0]
2015-11-05 20:43:12 +00:00
inp = "printer"
2015-11-03 01:18:44 +00:00
return kittenrex.sub("baby "+ inp, regex.sub(inp, fact))