Skip to content

Commit

Permalink
Merge pull request #25 from ManagedKube/nexus7
Browse files Browse the repository at this point in the history
nexus7
  • Loading branch information
sekka1 authored Aug 18, 2024
2 parents d1c4ff7 + fef2573 commit 4999150
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nexus-trusted-traveler-scheduler-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations
from datetime import datetime
import re

from typing import TYPE_CHECKING, List

Expand Down Expand Up @@ -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:
"""
Expand Down

0 comments on commit 4999150

Please sign in to comment.