2021-01-09 09:58:56 -05:00
|
|
|
import logging
|
|
|
|
import re
|
|
|
|
|
|
|
|
from aprsd import messaging, plugin
|
|
|
|
|
|
|
|
LOG = logging.getLogger("APRSD")
|
|
|
|
|
|
|
|
|
|
|
|
class QueryPlugin(plugin.APRSDPluginBase):
|
|
|
|
"""Query command."""
|
|
|
|
|
|
|
|
version = "1.0"
|
|
|
|
command_regex = r"^\?.*"
|
|
|
|
command_name = "query"
|
|
|
|
|
|
|
|
def command(self, fromcall, message, ack):
|
|
|
|
LOG.info("Query COMMAND")
|
|
|
|
|
|
|
|
tracker = messaging.MsgTrack()
|
|
|
|
reply = "Pending Messages ({})".format(len(tracker))
|
|
|
|
|
|
|
|
searchstring = "^" + self.config["ham"]["callsign"] + ".*"
|
|
|
|
# only I can do admin commands
|
|
|
|
if re.search(searchstring, fromcall):
|
2021-01-09 18:50:04 -05:00
|
|
|
r = re.search(r"^\?[rR].*", message)
|
2021-01-09 09:58:56 -05:00
|
|
|
if r is not None:
|
|
|
|
if len(tracker) > 0:
|
|
|
|
reply = "Resend ALL Delayed msgs"
|
|
|
|
LOG.debug(reply)
|
|
|
|
tracker.restart_delayed()
|
|
|
|
else:
|
|
|
|
reply = "No Delayed Msgs"
|
|
|
|
LOG.debug(reply)
|
|
|
|
return reply
|
|
|
|
|
2021-01-09 18:50:04 -05:00
|
|
|
r = re.search(r"^\?[fF].*", message)
|
2021-01-09 09:58:56 -05:00
|
|
|
if r is not None:
|
|
|
|
reply = "Deleting ALL Delayed msgs."
|
|
|
|
LOG.debug(reply)
|
|
|
|
tracker.flush()
|
|
|
|
return reply
|
|
|
|
|
|
|
|
return reply
|