h/plugins/printerfact.py

19 lines
544 B
Python
Raw 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)
@hook.regex("PHP sadness$")
def php_fact(inp):
return "http://phpsadness.com/sad/" + str(random.randint(0,53))
2015-11-05 20:43:12 +00:00
@hook.regex("printer fact$")
@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))