Add ability to do lookups of pony episodes in discordian time

This commit is contained in:
Christine Dodrill 2015-11-10 20:34:26 -08:00
parent ec3e25ed1b
commit 2630ae28be
1 changed files with 13 additions and 5 deletions

View File

@ -1,20 +1,28 @@
from util import hook from util import hook
from ddate.base import DDate
import datetime import datetime
import ponyapi import ponyapi
def get_time(ep):
now = datetime.datetime(2006, 1, 1)
now = now.now()
then = now.fromtimestamp(int(ep[u"air_date"]))
td = then-now
return now, then, td
@hook.command @hook.command
def when(inp, say=None): def when(inp, say=None):
#"Shows the countdown to the new episode of My Little Pony: Friendship is Magic!" #"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() ep = ponyapi.newest()
then = now.fromtimestamp(int(ep[u"air_date"])) now, then, td = get_time(ep)
td = then-now
seasonep = "" seasonep = ""
if inp == "discord":
return "%s will air on %s" % (ep[u"name"], DDate(then))
if ep[u"is_movie"]: if ep[u"is_movie"]:
seasonep = "(a movie)" seasonep = "(a movie)"
else: else: