2021-07-14 20:50:41 -04:00
|
|
|
import logging
|
|
|
|
|
2021-12-06 14:11:34 -05:00
|
|
|
from aprsd import messaging, packets, plugin
|
2021-07-14 20:50:41 -04:00
|
|
|
|
2021-08-23 12:14:19 -04:00
|
|
|
|
2021-07-14 20:50:41 -04:00
|
|
|
LOG = logging.getLogger("APRSD")
|
|
|
|
|
|
|
|
|
2021-08-19 11:39:29 -04:00
|
|
|
class NotifySeenPlugin(plugin.APRSDWatchListPluginBase):
|
2021-07-17 14:30:29 -04:00
|
|
|
"""Notification plugin to send seen message for callsign.
|
|
|
|
|
|
|
|
|
|
|
|
This plugin will track callsigns in the watch list and report
|
|
|
|
when a callsign has been seen when the last time they were
|
|
|
|
seen was older than the configured age limit.
|
|
|
|
"""
|
2021-07-14 20:50:41 -04:00
|
|
|
|
2021-11-12 11:36:22 -05:00
|
|
|
short_description = "Notify me when a CALLSIGN is recently seen on APRS-IS"
|
2021-07-14 20:50:41 -04:00
|
|
|
|
2021-08-19 11:39:29 -04:00
|
|
|
def process(self, packet):
|
2021-10-06 12:08:29 -04:00
|
|
|
LOG.info("NotifySeenPlugin")
|
2021-07-14 20:50:41 -04:00
|
|
|
|
|
|
|
notify_callsign = self.config["aprsd"]["watch_list"]["alert_callsign"]
|
|
|
|
fromcall = packet.get("from")
|
|
|
|
|
2021-07-17 14:30:29 -04:00
|
|
|
wl = packets.WatchList()
|
|
|
|
age = wl.age(fromcall)
|
|
|
|
|
|
|
|
if wl.is_old(packet["from"]):
|
|
|
|
LOG.info(
|
|
|
|
"NOTIFY {} last seen {} max age={}".format(
|
|
|
|
fromcall,
|
|
|
|
age,
|
|
|
|
wl.max_delta(),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
packet_type = packets.get_packet_type(packet)
|
|
|
|
# we shouldn't notify the alert user that they are online.
|
|
|
|
if fromcall != notify_callsign:
|
2021-12-06 14:11:34 -05:00
|
|
|
msg = messaging.TextMessage(
|
|
|
|
self.config["aprs"]["login"],
|
|
|
|
notify_callsign,
|
|
|
|
f"{fromcall} was just seen by type:'{packet_type}'",
|
|
|
|
# We don't need to keep this around if it doesn't go thru
|
|
|
|
allow_delay=False,
|
|
|
|
)
|
|
|
|
return msg
|
2021-07-17 14:30:29 -04:00
|
|
|
else:
|
|
|
|
LOG.debug(
|
|
|
|
"Not old enough to notify callsign '{}' : {} < {}".format(
|
|
|
|
fromcall,
|
|
|
|
age,
|
|
|
|
wl.max_delta(),
|
|
|
|
),
|
|
|
|
)
|