From 58cc0826ef44a7c26985c596d16a51d1b5eb886a Mon Sep 17 00:00:00 2001 From: oloturia Date: Sat, 21 Mar 2020 17:46:26 +0100 Subject: [PATCH] Fixed a silly bug that triggered the alarm if it was set before the present time --- buonanotte.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/buonanotte.py b/buonanotte.py index 1ddc03e..df42dd1 100644 --- a/buonanotte.py +++ b/buonanotte.py @@ -42,8 +42,13 @@ class goodListener(StreamListener): return try: result = goodNight.group() + if (parser.parse(result) < datetime.datetime.now()): + delta = 1 + else: + delta = 0 + datesleep = (datetime.datetime.now()+datetime.timedelta(days=delta)).strftime("%Y/%m/%d")+" "+result with open("schedule.csv","a") as file: - row = [result,account,lang] + row = [datesleep,account,lang] writer = csv.writer(file) writer.writerow(row) mastodon.toot(greet+account+reminder+result) @@ -55,7 +60,7 @@ class goodListener(StreamListener): reader = csv.reader(file) sentToBed = [] for line,row in enumerate(reader): - if parser.parse(row[0]) < datetime.datetime.now(): + if (parser.parse(row[0]) < datetime.datetime.now()): greet = languages[row[2]][0] goodnight = languages[row[2]][2] mastodon.toot(greet+row[1]+goodnight)