Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #28 from BrianMitchL/alert-crash-fix
Browse files Browse the repository at this point in the history
Fix crash when caching an alert with no expiry time
  • Loading branch information
BrianMitchL committed Sep 2, 2017
2 parents 4e5d677 + ac3f2fc commit a6be258
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion weatherBot.py
Expand Up @@ -329,7 +329,11 @@ def tweet_logic(weather_data, wb_string):
# weather alerts
for alert in weather_data.alerts:
if alert.sha() not in CACHE['throttles'] and not alert.expired(now_utc):
CACHE['throttles'][alert.sha()] = alert.expires
try:
CACHE['throttles'][alert.sha()] = alert.expires
except AttributeError:
# most alerts are probably done after 3 days
CACHE['throttles'][alert.sha()] = alert.time + timedelta(days=3)
do_tweet(wb_string.alert(alert, weather_data.timezone),
weather_data.location,
CONFIG['basic']['tweet_location'],
Expand Down

0 comments on commit a6be258

Please sign in to comment.