diff --git a/.github/workflows/nexus-trusted-traveler-scheduler-1.yml b/.github/workflows/nexus-trusted-traveler-scheduler-1.yml index 8e126b0a..78efbf27 100644 --- a/.github/workflows/nexus-trusted-traveler-scheduler-1.yml +++ b/.github/workflows/nexus-trusted-traveler-scheduler-1.yml @@ -23,12 +23,12 @@ on: ## │ │ │ │ │ ## │ │ │ │ │ ## * * * * * -# schedule: + schedule: # ## Testing run every 5 minutes # - cron: '*/5 * * * *' ## Run every 5 hours on minute 37 - # - cron: '37 */5 * * *' + - cron: '37 */5 * * *' env: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN_NEXUS }} # Sends to the nexus channel. In the format of: slack://xxx/xxx/xxx diff --git a/nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py b/nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py index c7f30f81..fe491773 100644 --- a/nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py +++ b/nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py @@ -1,5 +1,6 @@ from __future__ import annotations from datetime import datetime +import re from typing import TYPE_CHECKING, List @@ -52,15 +53,25 @@ def send_notification(self, body: str, level: int = 1) -> None: title = "Trusted Traveler Scheduler" - apobj = apprise.Apprise(self.notification_urls) - result = apobj.notify(title=title, body=body, body_format=apprise.NotifyFormat.TEXT) + pattern = r"Sun|Fri|Sat" + match = re.search(pattern, body) + print("GarDebug: in sending notification") - # If you encounter Apprise errors, https://github.com/caronc/apprise/wiki/Development_LogCapture - # may be useful. - if result is None: - print('{datetime.today():%Y/%m/%d %H:%M:%S}: error: No notifications sent (configuration error)') - elif result is False: - print('{datetime.today():%Y/%m/%d %H:%M:%S}: error: At least 1 notification failed to send') + if match: + print(f"GarDebug: Sending notification: {body}") + + apobj = apprise.Apprise(self.notification_urls) + result = apobj.notify(title=title, body=body, body_format=apprise.NotifyFormat.TEXT) + + # If you encounter Apprise errors, https://github.com/caronc/apprise/wiki/Development_LogCapture + # may be useful. + if result is None: + print('{datetime.today():%Y/%m/%d %H:%M:%S}: error: No notifications sent (configuration error)') + elif result is False: + print('{datetime.today():%Y/%m/%d %H:%M:%S}: error: At least 1 notification failed to send') + + else: + print(f"GarDebug: Skipping notification: {body}") def new_appointment(self, location_id: int, appointments: List[Schedule]) -> None: """