|
|
@@ -28,7 +28,7 @@ if __name__ == '__main__':
|
|
|
|
|
|
timestamp_when_okay = int(status['timestamp'])
|
|
|
if status['integer'] == 0:
|
|
|
- seconds_in_hosp = model.extract_hospital_time(status['text'], _debug=True)
|
|
|
+ seconds_in_hosp = model.extract_hospital_time(status['text'], _debug=False)
|
|
|
timestamp_when_okay += seconds_in_hosp
|
|
|
if old_status != status['integer']:
|
|
|
calculate_next_opportunity = True
|
|
|
@@ -56,20 +56,36 @@ if __name__ == '__main__':
|
|
|
attack_time_time = attack_time_object.format('hh:mm A')
|
|
|
minutes_to_go = math.floor(seconds_to_go / 60)
|
|
|
t = f'In < {minutes_to_go} mins ({attack_time_time}) {player_name} [{player_id}] reaches level IV'
|
|
|
- print(t)
|
|
|
+ # print(t)
|
|
|
status['time_string'] = t
|
|
|
|
|
|
if minutes_to_go < 20 and minutes_to_go % 5 == 0 and minutes_to_go != 0:
|
|
|
- name_alert = status['name']
|
|
|
- id_alert = status['id']
|
|
|
- url_alert = f'https://www.torn.com/profiles.php?XID={id_alert}'
|
|
|
- add_here = ''
|
|
|
- if 8 < minutes_to_go < 12:
|
|
|
- add_here = '@here '
|
|
|
- alert = add_here + f'Alert: {minutes_to_go} mins to attack [{name_alert} [{id_alert}]]({url_alert}). ' + \
|
|
|
- f'Be there at {attack_time_time}!'
|
|
|
- print('Sending alert')
|
|
|
- view.send_alert(alert)
|
|
|
+ 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}
|
|
|
+ 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 8 < minutes_to_go < 12:
|
|
|
+ add_here = '@here '
|
|
|
+ alert = add_here + f'Alert: {minutes_to_go} mins to attack [{name_alert} [{id_alert}]]({url_alert}). ' + \
|
|
|
+ f'Be there at {attack_time_time}!'
|
|
|
+ print('Sending alert')
|
|
|
+ view.send_alert(alert)
|
|
|
+
|
|
|
+ # We just sent an alert
|
|
|
+ temp_status_json['alert'][str(minutes_to_go)] = True
|
|
|
+ print(temp_status_json)
|
|
|
+ write_file = open(f'status-{player_id}.json', 'w')
|
|
|
+ write_file.write(temp_status_json)
|
|
|
+ write_file.close()
|
|
|
+ write_file.close()
|
|
|
+
|
|
|
|
|
|
if send_message:
|
|
|
view.send_message(status)
|