diff --git a/aprsd/plugin.py b/aprsd/plugin.py index 15027fe..fe5efee 100644 --- a/aprsd/plugin.py +++ b/aprsd/plugin.py @@ -205,27 +205,27 @@ class APRSDRegexCommandPluginBase(APRSDPluginBase, metaclass=abc.ABCMeta): @hookimpl def filter(self, packet): - if self.enabled: - result = None + result = None - message = packet.get("message_text", None) - msg_format = packet.get("format", None) - tocall = packet.get("addresse", None) + message = packet.get("message_text", None) + msg_format = packet.get("format", None) + tocall = packet.get("addresse", None) - # Only process messages destined for us - # and is an APRS message format and has a message. - if ( - tocall == self.config["aprs"]["login"] - and msg_format == "message" - and message - ): - if re.search(self.command_regex, message): - self.rx_inc() + # Only process messages destined for us + # and is an APRS message format and has a message. + if ( + tocall == self.config["aprs"]["login"] + and msg_format == "message" + and message + ): + if re.search(self.command_regex, message): + self.rx_inc() + if self.enabled: result = self.process(packet) if result: self.tx_inc() - else: - LOG.warning(f"{self.__class__} is not enabled.") + else: + LOG.warning(f"{self.__class__} isn't enabled.") return result diff --git a/aprsd/threads.py b/aprsd/threads.py index e7ab767..fbe47f3 100644 --- a/aprsd/threads.py +++ b/aprsd/threads.py @@ -253,15 +253,21 @@ class APRSDProcessPacketThread(APRSDThread): replied = True for subreply in reply: LOG.debug(f"Sending '{subreply}'") - - msg = messaging.TextMessage( - self.config["aprs"]["login"], - fromcall, - subreply, - transport=self.transport, - ) - msg.send() - + if isinstance(subreply, messaging.Message): + subreply.send() + else: + msg = messaging.TextMessage( + self.config["aprs"]["login"], + fromcall, + subreply, + transport=self.transport, + ) + msg.send() + elif isinstance(reply, messaging.Message): + # We have a message based object. + LOG.debug(f"Sending '{reply}'") + reply.send() + replied = True else: replied = True # A plugin can return a null message flag which signals