Update 'notify/src/ntfy.py'
This commit is contained in:
1 parent
d29d9e16f0
commit
a13f099e14
1 file changed
+3
-3
+3
-3
@@ -3,15 +3,15 @@ import requests
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
last_notification_time = None
|
||||
last_notification_time = {}
|
||||
|
||||
|
||||
def send_rate_limited_notification(event_id, camera, object_label, score, quiet_period=1):
|
||||
global last_notification_time
|
||||
|
||||
now = datetime.now()
|
||||
if last_notification_time is None or now - last_notification_time >= timedelta(minutes=quiet_period):
|
||||
last_notification_time = now
|
||||
if camera not in last_notification_time or now - last_notification_time[camera] >= timedelta(minutes=quiet_period):
|
||||
last_notification_time[camera] = now
|
||||
send_notification(event_id, camera, object_label, score, priority=3)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user