Exemplo n.º 1
0
 def answer(self, communicator, message):
     """let the assistant answer to the given message
         @param communicator the communicator object used for communication
         @param message string, the assistant should answer to"""
     language = Config.get_instance().get("general", "language")
     query = Query(message.lower(), communicator, language)
     modules = mManager.get_instance().get_modules()
     if not modules:
         communicator.say(self.strings["NO_MODULES"])
         return
     for module in modules:
         """traverse modules and match their regex keys"""
         module = module.get_submodule(query.get_language())
         if module is not None:
             for key_regex, method in module.get_key_regexes().items():
                 if re.match(key_regex, message):
                     try:
                         method(query)
                     except ImpossibleActionError as e:
                         communicator.say(self.strings["KNOWN_ERROR"] +
                                          str(e))
                     except ModuleError as e:
                         communicator.say(self.strings["UNKNOWN_ERROR"])
                         self.logger.error(str(e))
                     except Exception as e:
                         communicator.say(self.strings["UNKNOWN_ERROR"])
                         self.logger.error(str(e))
                     return
     communicator.say(self.strings["NOT_PROCESSABLE"])
Exemplo n.º 2
0
 def deactivate(self):
     """deactivates the module"""
     mManager.get_instance().remove_module(self)
     mManager.get_instance().remove_media_module(self)
     self.logger.info(self.__class__.__name__ + " deactivated")
Exemplo n.º 3
0
        def load_modules(self):
            module_manager = ModuleManager.get_instance()

            for module in module_manager.get_modules():
                module.configure()
Exemplo n.º 4
0
 def activate(self):
     """activates the module"""
     mManager.get_instance().add_module(self)
     self.logger.info(self.__class__.__name__ + " activated")
Exemplo n.º 5
0
 def briefing(query):
     module_manager = ModuleManager.get_instance()
     query.set_text('')
     for briefing_module in module_manager.get_briefing_modules():
         briefing_module.get_submodule(
             query.get_language()).briefing_action(query)