improved trigger code
This commit is contained in:
+17
-5
@@ -6,6 +6,7 @@ from exceptions import MissingConfig, TriggerImportError
|
||||
class Trigger(AppClass):
|
||||
def __init__(self, _config: Config) -> None:
|
||||
super().__init__(_config)
|
||||
self.active: bool = False
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
@@ -23,8 +24,19 @@ class Trigger(AppClass):
|
||||
raise MissingConfig(f"Trigger {self.name} hasn't been properly configured")
|
||||
return _config
|
||||
|
||||
def run(self) -> bool:
|
||||
# return True if Trigger is valid
|
||||
raise TriggerImportError(
|
||||
"the Trigger class can't used directly, but must be inherited in a trigger specific class"
|
||||
)
|
||||
def run(self) -> None:
|
||||
# this is the main function of the trigger class and has to stay active by using a while True loop
|
||||
|
||||
while True:
|
||||
raise TriggerImportError(
|
||||
"the Trigger class can't used directly, but must be inherited in a trigger specific class"
|
||||
)
|
||||
|
||||
async def async_run(self) -> None:
|
||||
# this is the main function of the trigger class and can be used to execute a callback function
|
||||
|
||||
while True:
|
||||
raise TriggerImportError(
|
||||
"the Trigger class can't used directly, but must be inherited in a trigger specific class"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user