summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorRosyid Haryadi <rosyid_haryadi@protonmail.com>2024-07-28 00:24:41 +0700
committerRosyid Haryadi <rosyid_haryadi@protonmail.com>2024-07-28 00:24:41 +0700
commit96ab3ab2f586be54e6af367fc0bbbbbd8ee13926 (patch)
treea8f0780f23f90ba10ddb356698951935d03ddfb9 /main.py
parentaf5bc873b2515b2c8c5b71c22379fbf158985e00 (diff)
fix handle connection problem
Diffstat (limited to 'main.py')
-rw-r--r--main.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/main.py b/main.py
index 89b9e6b..66eadf7 100644
--- a/main.py
+++ b/main.py
@@ -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)