From 2630ae28be6585e7cdadccdd2b42dce5b6b3762c Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Tue, 10 Nov 2015 20:34:26 -0800 Subject: [PATCH] Add ability to do lookups of pony episodes in discordian time --- plugins/pony.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/pony.py b/plugins/pony.py index 2787e96..05117d6 100644 --- a/plugins/pony.py +++ b/plugins/pony.py @@ -1,20 +1,28 @@ from util import hook +from ddate.base import DDate import datetime 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 def when(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 - + now, then, td = get_time(ep) seasonep = "" + if inp == "discord": + return "%s will air on %s" % (ep[u"name"], DDate(then)) + if ep[u"is_movie"]: seasonep = "(a movie)" else: