def legal(inp): now = datetime.datetime.now() name = inp.replace(' ', '_') html = http.get_html('http://rottentomatoes.com/celebrity/%s/' % (name)) date = html.xpath('//dl[@class="bottom_divider"]/dd/text()')[0] #return date info = date.split(' ') month = info[0] birth_day = info[1].strip(",") birth_year = info[2] birth_month = months[month] birthdate = datetime.date(int(birth_year), int(birth_month), int(birth_day)) age = now.year - int(birth_year) if age >= 18: return "legal - is %s" % (age) else: year_18 = int(birth_year) + 18 birthday_18 = "%s %s %s" % (birth_day, full_month[month], year_18) #return birthday_18 #return "%s :: %s" % (birth_month, str(day_18)) return "%s will be 18 in %s" % (inp, timesince.timeuntil(birthdate, now=birthday_18)) return months[birth_month]
def allowed(db, nick, nick_vote): time_restriction = 3600 db.execute("""DELETE FROM karma_voters WHERE ? - epoch >= 3600""", (time.time(), )) db.commit() check = db.execute( """SELECT epoch FROM karma_voters WHERE voter=? AND votee=?""", (nick.lower(), nick_vote.lower())).fetchone() if check: check = check[0] if time.time() - check >= time_restriction: db.execute( """INSERT OR REPLACE INTO karma_voters( voter, votee, epoch) values(?,?,?)""", (nick.lower(), nick_vote.lower(), time.time())) db.commit() return True, 0 else: return False, timesince.timeuntil(check, now=time.time() - time_restriction) else: db.execute( """INSERT OR REPLACE INTO karma_voters( voter, votee, epoch) values(?,?,?)""", (nick.lower(), nick_vote.lower(), time.time())) db.commit() return True, 0
def allowed(db, nick, nick_vote): time_restriction = 3600 db.execute("""DELETE FROM karma_voters WHERE ? - epoch >= 3600""", (time.time(),)) db.commit() check = db.execute("""SELECT epoch FROM karma_voters WHERE voter=? AND votee=?""", (nick.lower(), nick_vote.lower())).fetchone() if check: check = check[0] if time.time() - check >= time_restriction: db.execute("""INSERT OR REPLACE INTO karma_voters( voter, votee, epoch) values(?,?,?)""", (nick.lower(), nick_vote.lower(), time.time())) db.commit() return True, 0 else: return False, timesince.timeuntil(check, now=time.time()-time_restriction) else: db.execute("""INSERT OR REPLACE INTO karma_voters( voter, votee, epoch) values(?,?,?)""", (nick.lower(), nick_vote.lower(), time.time())) db.commit() return True, 0
def tv_next(inp): ".tv_next <series> -- get the next episode of <series>" episodes = get_episodes_for_series(inp) if episodes["error"]: return episodes["error"] series_name = episodes["name"] ended = episodes["ended"] episodes = episodes["episodes"] if ended: return "%s has ended." % series_name next_eps = [] today = datetime.date.today() for episode in reversed(episodes): ep_info = get_episode_info(episode) if ep_info is None: continue (episode_air_date, airdate, episode_desc) = ep_info if airdate > today: next_eps = [ "%s (%s) (%s)" % ( episode_air_date, timesince.timeuntil( datetime.datetime.strptime(episode_air_date, "%Y-%m-%d") ), episode_desc, ) ] elif airdate == today: next_eps = ["Today (%s)" % episode_desc] + next_eps else: # we're iterating in reverse order with newest episodes last # so, as soon as we're past today, break out of loop break if not next_eps: return "there are no new episodes scheduled for %s" % series_name if len(next_eps) == 1: return "the next episode of %s airs %s" % (series_name, next_eps[0]) else: next_eps = ", ".join(next_eps) return "the next episodes of %s: %s" % (series_name, next_eps)
def tv_next(inp): ".tv_next <series> -- get the next episode of <series>" episodes = get_episodes_for_series(inp) if episodes["error"]: return episodes["error"] series_name = episodes["name"] ended = episodes["ended"] episodes = episodes["episodes"] if ended: return "%s has ended." % series_name next_eps = [] today = datetime.date.today() for episode in reversed(episodes): ep_info = get_episode_info(episode) if ep_info is None: continue (episode_air_date, airdate, episode_desc) = ep_info if airdate > today: next_eps = [ "%s (%s) (%s)" % ( episode_air_date, timesince.timeuntil(datetime.datetime.strptime(episode_air_date, "%Y-%m-%d")), episode_desc, ) ] elif airdate == today: next_eps = ["Today (%s)" % episode_desc] + next_eps else: # we're iterating in reverse order with newest episodes last # so, as soon as we're past today, break out of loop break if not next_eps: return "there are no new episodes scheduled for %s" % series_name if len(next_eps) == 1: return "the next episode of %s airs %s" % (series_name, next_eps[0]) else: next_eps = ", ".join(next_eps) return "the next episodes of %s: %s" % (series_name, next_eps)
def part(inp, say=None, conn=None, chan=None, notice=None): """part [channel] [delay=1] - Leaves a channel with a given delay. Channel and delay default to the current channel and 1 respectively.""" if inp: if len(inp.split(' ', 1)) == 2: target, delay = inp.split(' ', 1) else: if inp.isdigit(): target, delay = chan, int(inp) else: target, delay = inp, None else: target, delay = chan, None if delay: say("Parting channel in {}...".format(timesince.timeuntil(time.time() + delay))) time.sleep(delay) notice("Attempting to leave {}...".format(target)) conn.send("PART " + target)
def timetotheendofallthings(inp): return "There is %s left till the end of all things."%(timesince.timeuntil(datetime.datetime(2023, 8, 12, 0, 0)))
def kinksmeetup(inp): return "There is %s left till #KinksMeetup2015 (TBC)"%(timesince.timeuntil(datetime.datetime(2015, 4, 17, 0, 0)))
def kinksmeetup(inp): return "There is %s left till #KinksMeetup2015 (TBC)" % ( timesince.timeuntil(datetime.datetime(2015, 4, 17, 0, 0)))
def timetotheendofallthings(inp): return "There is %s left till the end of all things." % ( timesince.timeuntil(datetime.datetime(2023, 8, 12, 0, 0)))