Exemple #1
0
 def g(f):
     if not syntaxes:
         raise ValueError(
             "Must provide at least one valid syntax for each command")
     f.command_syntaxes = syntaxes
     f.command_grammars = []
     f.storable = options.get("storable", True)
     for syntax in syntaxes:
         f.command_grammars += create_grammars(syntax)
     return f
Exemple #2
0
 def __init__(self, name="Watson", command_names=(), log_file='/var/log/chatbot.log', log_level=logging.INFO):
     self._modules = {}
     self._commands = {}
     self.state = State(self)
     self.welcome_phrase = self.welcome_phrase % name
     self.command_grammars = create_grammars("/".join(command_names) + " <phrase>")
     
     formatter = logging.Formatter('[%(asctime)s %(levelname)s] - %(message)s')
     
     handler = logging.FileHandler(log_file)
     handler.setFormatter(formatter)
     
     self.logger = logging.getLogger("watson")
     self.logger.addHandler(handler)
     self.logger.setLevel(log_level)
Exemple #3
0
    def __init__(self,
                 name="Watson",
                 command_names=(),
                 log_file='/var/log/chatbot.log',
                 log_level=logging.INFO):
        self._modules = {}
        self._commands = {}
        self.state = State(self)
        self.welcome_phrase = self.welcome_phrase % name
        self.command_grammars = create_grammars("/".join(command_names) +
                                                " <phrase>")

        formatter = logging.Formatter(
            '[%(asctime)s %(levelname)s] - %(message)s')

        handler = logging.FileHandler(log_file)
        handler.setFormatter(formatter)

        self.logger = logging.getLogger("watson")
        self.logger.addHandler(handler)
        self.logger.setLevel(log_level)