mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-01-11 11:10:08 +01:00
add plugin readme, wildcardhandler
This commit is contained in:
parent
e04ba4b812
commit
8097b4bb12
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
35
boswatch/utils/wildcard.py
Normal file
35
boswatch/utils/wildcard.py
Normal file
|
|
@ -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
|
||||
19
plugins/readme.md
Normal file
19
plugins/readme.md
Normal file
|
|
@ -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
|
||||
|
||||
Loading…
Reference in a new issue