import os from mycroft import MycroftSkill, intent_handler class RunScriptSkill(MycroftSkill): def __init__(self): super().__init__() self.script_dir = None self.scripts = [] def initialize(self): self.settings_change_callback = self.on_settings_changed self.on_settings_changed() def on_settings_changed(self): self.script_dir = self.settings.get('script_dir') self.read_scripts_dir() def read_scripts_dir(self): if os.isdir(self.script_dir): self.scripts = os.listdir(script_dir) else: self.log.critical("The script_dir directory does not exist or can't be read") self.scripts = [] @intent_handler('RunScript.intent') def handle_run_script_intent(self, msg=None): script = msg.data.get('script', None) if script in self.scripts: self.speak_dialog('Running', {'script': script}) else: self.speak_dialog('NotFound', {'script': script}) def stop(self): pass def create_skill(): return RunScriptSkill()