Background-Daemon/daemon/daemon_plugin.py

31 lines
881 B
Python

"defines DaemonPlugin base class"
from abc import ABC, abstractmethod
from mycroft_bus_client import Message
class DaemonPlugin(ABC):
"Abstract class for Plugins to inherit from"
def __init__(self, daemon):
self.daemon = daemon
self.messagebus_client = daemon.messagebus_client
self.initialize()
def initialize(self):
"""
Initialize is called after the plugin object has been created. Add
any handlers for messagebus_client here
"""
def emit(self, event, data):
"Emits a message for OSD frontend"
self.daemon.emit(event, data)
def speak(self, utterance):
"Speaks the given string"
message = Message("speak", {"utterance": utterance})
self.messagebus_client.emit(message)
@abstractmethod
def check(self, data):
"Implement the core checks here"