Example #1
0
    def startup(self):
        log.debug("Startup called")
        self.bot = ChatbotEngine()

        scripts_directory = self.pluginPrefs.get("scriptsPath", "")
        if scripts_directory:
            self.load_scripts(scripts_directory)
        else:
            log.debug("Chatbot plugin is not configured.")
Example #2
0
    def setUp(self):

        self.errorlogger = testhandler.emit = Mock()
        self.ch = ChatbotEngine()
        self.scripts_dir = tempfile.mkdtemp()

        self.py_imports = b"""
from __future__ import unicode_literals
from chatbot_reply import Script, rule
"""
        self.py_encoding = b"# coding=utf-8\n"
Example #3
0
import logging

from chatbot_reply.six import text_type
from chatbot_reply.six.moves import input

from chatbot_reply import ChatbotEngine

if __name__ == "__main__":
    log = logging.getLogger()
    handler = logging.StreamHandler()
    formatter = logging.Formatter("[%(name)s] %(message)s")
    handler.setFormatter(formatter)
    log.addHandler(handler)
    log.setLevel(logging.ERROR)

    ch = ChatbotEngine()
    ch.load_script_directory("scripts")
    print ("Type /quit to quit, "
           "/botvars or /uservars to see values of variables, "
           "/reload to reload the scripts directory,"
           "/log plus debug, info, warning or error to set logging level.")
    while True:
        msg = text_type(input("You> "))
        if msg == "/quit":
            break
        elif msg == "/botvars":
            print(text_type(ch._botvars))
        elif msg == "/uservars":
            if "local" in ch._users:
                print(text_type(ch._users["local"].vars))
            else: