diff --git a/boswatch/packet/packet.py b/boswatch/packet/packet.py index 248a48a..ff75f7c 100644 --- a/boswatch/packet/packet.py +++ b/boswatch/packet/packet.py @@ -37,7 +37,7 @@ class Packet: try: self._packet = eval(bwPacket.strip()) except: - # todo can we repair teh packet anyway? + # todo can we repair the packet anyway? logging.exception("error while create packet from string") def __str__(self): @@ -97,7 +97,7 @@ class Packet: self.set("serverBuildDate", version.date) self.set("serverBranch", version.branch) - def infoToLog(self): + def printInfo(self): """!Print a info message to the log on INFO level. Contains the most useful info about this packet. @todo not complete yet - must be edit to print nice formatted messages on console diff --git a/boswatch/plugin/plugin.py b/boswatch/plugin/plugin.py index be256ff..0da24e2 100644 --- a/boswatch/plugin/plugin.py +++ b/boswatch/plugin/plugin.py @@ -62,9 +62,6 @@ class Plugin: self._pluginsActive -= 1 self.onUnload() - def _loadConfig(self): - pass - def _run(self, bwPacket): """!start an complete running turn of an plugin. Calls setup(), alarm() and teardown() in this order. diff --git a/boswatch/utils/wildcard.py b/boswatch/utils/wildcard.py new file mode 100644 index 0000000..478a517 --- /dev/null +++ b/boswatch/utils/wildcard.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +"""! + ____ ____ ______ __ __ __ _____ + / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ / + / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ < + / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ / +/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/ + German BOS Information Script + by Bastian Schroll + +@file: wildcard.py +@date: 15.01.2018 +@author: Bastian Schroll +@description: Little Helper to replace wildcards in stings +""" +import logging + +# from boswatch.module import file + +logging.debug("- %s loaded", __name__) + + +def replace(text, bwPacket): + + # static replacements + text.replace("%BR%", "\r\n") + text.replace("%LPAR%", "(").replace("%RPAR%", ")") + + # packet replacements + text.replace("%MODE%", bwPacket.getField("mode")) + text.replace("%FREQ%", bwPacket.getField("frequency")) + + # mode specific replacements + # if bwPacket diff --git a/plugins/readme.md b/plugins/readme.md new file mode 100644 index 0000000..0b6eb0b --- /dev/null +++ b/plugins/readme.md @@ -0,0 +1,19 @@ +## Eigene Plugins schreiben + +Um ein eigenes Plugin zu schrieben, sollte man sich am besten zuerst einmal das Plugin `template` ansehen. +Dies kann als Vorlage für das eigene Plugin genutzt werden. + +### 1.) Informationen anpassen +- Dateikopf anpassen +- Namen des Plugins vergeben in der __init__ Methode `super().__init__("template")` + +### 2.) Benötigte Methode überschreiben +Die Plugin Basisklasse bietet einige Methoden, welche vom Plugin überschrieben werden können. +- `onLoad()` wird direkt beim Import des Plugins ausgeführt +- `setup()` wird vor jeder Ausführung gerufen +- `fms()` wird bei einem FMS Paket ausgeführt +- `pocsag()` wird bei einem POCSAG Paket ausgeführt +- `zvei()` wird bei einem ZVEI Packet ausgeführt +- `teardown()` wird nach jeder Ausführung gerufen +- `onUnload()` wird beim Zerstören der Plugin Instanz zum Programmende ausgeführt +