Add handling of past dates

This commit is contained in:
Klaus-Uwe Mitterer 2015-03-19 18:44:12 +01:00
parent 1b8f4ec533
commit 249a8102f2

View file

@ -31,7 +31,7 @@ while True:
timeline = tweepy.Cursor(api.search, q=search, since_id=savepoint).items() timeline = tweepy.Cursor(api.search, q=search, since_id=savepoint).items()
for status in timeline: for status in timeline:
text = status.text.encode("UTF-8") text = status.text.decode("UTF-8")
sender = status.user.screen_name.encode("UTF-8") sender = status.user.screen_name.encode("UTF-8")
twid = int(status.id) twid = int(status.id)
if "storn" in text.lower(): if "storn" in text.lower():
@ -54,7 +54,10 @@ while True:
if date < datetime.datetime.now(): if date < datetime.datetime.now():
if date.date() == datetime.datetime.now().date(): if date.date() == datetime.datetime.now().date():
if (not date == datetime.datetime.now().replace(hour = 0, minute = 0, second = 0, microsecond = 0)) or "0:0" in text:
date += datetime.timedelta(days = 1) date += datetime.timedelta(days = 1)
else:
continue
else: else:
api.update_status("@%s Das war doch schon...?" % sender, twid) api.update_status("@%s Das war doch schon...?" % sender, twid)
continue continue