diff options
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -14,7 +14,9 @@ bot = Bot() def getScore(): - downloadCsv() + isSuccess = downloadCsv() + if not isSuccess: + return -1 myScore = readCSV() try: myScore = 100 * float(myScore) @@ -27,7 +29,8 @@ def processMessages(messages): if 'update' in (msg.lower() for msg in messages): logger.info("EXPLICIT SCORE UPDATE REQUESTED") score = getScore() - bot.sendMessage(f"Score leantime bulan ini = {score}%") + msg = f"Score leantime bulan ini = {score}%" if score >= 0 else "Connection problem with report dashboard" + bot.sendMessage(msg) @repeat(every().day.at("09:00")) @@ -37,8 +40,8 @@ def main(): weekday = today.weekday() if weekday not in [5, 6]: # jangan ganggu aku di akhir pekan myScore = getScore() - msg = f"Leantime score = {myScore}%. <i>Jangan lupa isi leantime</i>" - if (17 <= today.day <= 24) and myScore < 70: # seminggu sebelumnya udah ngingetin + msg = f"Leantime score = {myScore}%. <i>Jangan lupa isi leantime</i>" if myScore >= 0 else "Connection problem with report dashboard" + if (17 <= today.day <= 24) and (0 <= myScore < 70): # seminggu sebelumnya udah ngingetin msg = f'<b>WARNING!</b> SEKARANG UDAH TANGGAL {today.day}, SCORE LEANTIME MASIH {myScore}%' bot.sendMessage(msg) |