craigerl / aprsd

Amateur radio APRS daemon which listens for messages and responds. By KM6LYW.
Apache License 2.0
124 stars 19 forks source link

Created plugin.py for Command Plugins #15

Closed hemna closed 3 years ago

hemna commented 3 years ago

This patch adds the new APRSD Command Plugin architecture. All Comand plugins must implement the same object API, which includes plugin object is subclass of APRSDPluginBase version attribute command_regex attribute command method

When an APRS command is detected, then the regex is run against the command. If the command_regex matches, then the plugin's command() method will be called. If the command() method returns a string, then that string is sent as a reply to the APRS caller.

A new aprs.yml config section is added to support selecting which plugins to enable.

If you want all plugins enabled, then omit "enabled_plugins" entirely from the aprs section of the config.

To load custom plugins: 1) create a directory with an __init__.py file 2) Add a plugin.py file that contains your plugin

Look at the exmaples directory for an example plugin.

hemna commented 3 years ago

FWIW, the command_email hasn't been migrated to a core plugin, because it calls send_message() in a few places internally. Need to eventually refactor the messaging code into it's own file and email functions into it's own file. If the email command needs to call send_message() then it can simply call return message in the function. I just haven't looked at the function that much to determine if it's done after it calls send_message().

So for now command_email stays as a COMMAND_ENVELOPE mechanism.