Add skybot plugin

This plugin is unsupported. If it works for you, great. If it doesn't,
also great. It really is unsupported and no help on usage will be given.
This commit is contained in:
Christine Dodrill 2015-08-09 16:24:41 -07:00
parent 614fcf2990
commit 4713648a63
1 changed files with 40 additions and 0 deletions

40
client/skybot/pony.py Normal file
View File

@ -0,0 +1,40 @@
from util import hook
import datetime
import ponyapi
@hook.command
def countdown(inp, say=None):
"Shows the countdown to the new episode of My Little Pony: Friendship is Magic!"
now = datetime.datetime(2006, 1, 1)
now = now.now()
ep = ponyapi.newest()
then = now.fromtimestamp(int(ep[u"air_date"]))
td = then-now
seasonep = ""
if ep[u"is_movie"]:
seasonep = "(a movie)"
else:
seasonep = "(season %d episode %d)" % (ep[u"season"], ep[u"episode"])
reply = "%s %s will air on %s in %d days!" % (
ep[u"name"], seasonep, then.strftime("%a, %d %b %Y %H:%M:%S"),
td.days)
return reply
@hook.command
def randomep(inp):
"Shows a random episode of My Little Pony: Friendship is Magic"
ep = ponyapi.random()
seasonep = ""
if ep[u"is_movie"]:
seasonep = "(a movie)"
else:
seasonep = "(season %d episode %d)" % (ep[u"season"], ep[u"episode"])
return "%s %s" % (ep[u"name"], seasonep)