-
Notifications
You must be signed in to change notification settings - Fork 1
/
hamalertmessage.py
24 lines (21 loc) · 1.05 KB
/
hamalertmessage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import datetime
from pytz import timezone
class HamAlertMessage:
def __init__(self, req_body):
self.callsign = req_body.get('callsign', 'Unknown')
self.source = req_body.get('source', 'Unknown')
self.frequency = req_body.get('frequency', 'Unknown')
self.mode = req_body.get('mode', 'Unknown')
self.summitRef = req_body.get('summitRef', '')
self.wwffRef = req_body.get('wwffRef', '')
self.received_time_pt = datetime.datetime.now(timezone('US/Pacific'))
def spot_deeplink(self):
match self.source:
case "sotawatch":
return f"[{self.source}](https://sotl.as/activators/{self.callsign})"
case "pota":
return f"[{self.source}](https://api.pota.app/spot/comments/{self.callsign}/{self.wwffRef})"
case _:
return ""
def __str__(self):
return f'{self.received_time_pt.strftime("%H:%M")} | {self.callsign} | {self.spot_deeplink()} | freq: {self.frequency} | mode: {self.mode} | loc: {self.summitRef}{self.wwffRef}'