Kaynağa Gözat

Add 1 minute alert

Foppe Hemminga 6 yıl önce
ebeveyn
işleme
edab28c7a2
1 değiştirilmiş dosya ile 5 ekleme ve 3 silme
  1. 5 3
      main.py

+ 5 - 3
main.py

@@ -42,7 +42,7 @@ if __name__ == '__main__':
         if write_file_next:
             # summary = {'text': status["status"], 'roman': status["roman"], 'integer': status["integer"]}
             if status['integer'] <= 2:
-                status['alert'] = {'15': False, '10': False, '5': False, '0': False}
+                status['alert'] = {'15': False, '10': False, '5': False, '1': False}
             summary_json = json.dumps(status, indent=2)
             print(summary_json)
             write_file = open(f'status-{player_id}.json', 'w')
@@ -59,18 +59,20 @@ if __name__ == '__main__':
         # print(t)
         status['time_string'] = t
 
-        if minutes_to_go < 20 and minutes_to_go % 5 == 0 and minutes_to_go != 0:
+        if (minutes_to_go < 20 and minutes_to_go % 5 == 0 and minutes_to_go != 0) or minutes_to_go == 1:
             temp_status_json, _ = model.get_json_file(player_id)
             if 'alert' in temp_status_json:
                 alerts = old_status['alert']
             else:
-                alerts = {'15': False, '10': False, '5': False, '0': False}
+                alerts = {'15': False, '10': False, '5': False, '1': False}
             if not alerts[str(minutes_to_go)]:
                 # We have not sent this alert before
                 name_alert = status['name']
                 id_alert = status['id']
                 url_alert = f'https://www.torn.com/profiles.php?XID={id_alert}'
                 add_here = ''
+                if minutes_to_go == 1:
+                    add_here = '@here '
                 if 8 < minutes_to_go < 12:
                     add_here = '@here '
                 alert = add_here + \