Exemple #1
0
def toBot():
    if (os.path.isfile(".bot_engage")):
        print "You can only run one instance of Clarissa."
    else:
        swearNum = 1
        messageToBot = raw_input("Message: ")
        if (messageToBot == "--add-command"):
            writeCommand(command=raw_input("Command: "),
                         response=raw_input("Responses: "))
            reload(bot)
        elif (messageToBot == "kill-bot"):
            exit()
        elif (messageToBot == "--clear-commands"):
            #os.remove("commands.bot")
            #os.remove("responses.bot")
            os.remove("bot_response.py")
            writeCommand("Hello", "Hi")
            print "Cleared commands"
        elif (messageToBot == "learn"):
            learner.learn(db_support=False)
        elif (messageToBot == "--get-commands"):
            commandsList = open("commands.list", "r")
            print commandsList.read()
        bot.getResponse(messageToBot)
        toBot()
Exemple #2
0
def toBot():
    reload(bot)
    reload(learner)
    if (os.path.isfile(".bot_engage")):
        print("You can only run one instance of Clarissa.")
    else:
        swearNum = 1
        setup_ext = open(".setup_ext", 'r')
        for line in setup_ext.readlines():
            if "install=" in line:
                os.environ['CLARISSA_PATH'] = line.replace("install=", "")
        os.environ['USER_NAME'] = r.getClarissaSetting("user.name").replace(
            "\n", "")
        messageToBot = input(os.environ['USER_NAME'].replace("\n", "") + ": ")
        if (messageToBot == "--add-command"):
            writeCommand(command=input("Command: "),
                         response=input("Responses: "))
            reload(bot)
        elif (messageToBot == "kill-bot"):
            bot.getResponse("kill-bot")
            exit()
        elif (messageToBot == "--clear-commands"):
            #os.remove("commands.bot")
            #os.remove("responses.bot")]
            print("Cleared commands")
            exit()
        elif (messageToBot == "learn"):
            learner.learn(db_support=False)
        elif (messageToBot == "--get-commands"):
            commandsList = open("commands.list", "r")
            print(commandsList.read())
        elif (messageToBot == "--get-logs"):
            logs = open('chat.log', 'r')
            print(logs.read())
        elif (messageToBot == "--update-clarissa"):
            urllib.urlopen("https://softy.xyz/apps/sites/clarissa/get.php")
            response = urllib.request.urlopen(
                "https://softy.xyz/apps/sites/clarissa/clarissa.json")
            import json
            file = json.loads(response.read())
            print(file['command'])
        elif ("Call me " in messageToBot):
            w.setClarissaSetting("user.name",
                                 messageToBot.replace("Call me ", ""))
        elif ("call me " in messageToBot):
            w.setClarissaSetting("user.name",
                                 messageToBot.replace("call me ", ""))
        log.log("chat.log", messageToBot)
        if (r.getClarissaSetting("ro.Clarissa.FROM_SERVER") is "true"):
            print("Get the response from a server")
        else:
            bot.getResponse(messageToBot)
        toBot()
Exemple #3
0

swearNum = 0

try:
    if ("--add-command" in sys.argv):
        writeCommand(command=sys.argv[2], response=sys.argv[3])
        reload(bot)
    elif ("--clear-commands" in sys.argv):
        #os.remove("commands.bot")
        #os.remove("responses.bot")
        os.remove("bot_response.py")
        writeCommand("Hello", "Hi")
        print("Cleared commands")
    elif ("learn" in sys.argv):
        learner.learn(db_support=False)
    elif ("--get-commands" in sys.argv):
        commandsList = open("commands.list", "r")
        print(commandsList.read())
    elif ("--update-clarissa" in sys.argv):
        os.system("python update.py")
    elif ("--get-logs" in sys.argv):
        logs = open('chat.log', 'r')
        print(logs.read())
    elif (sys.argv[1] == "set.name"):
        w.setClarissaSetting("user.name", sys.argv[2])
    elif (sys.argv[1] == "--get-setting"):
        print(getClarissaSetting(sys.argv[2]))
    elif (sys.argv[1] == "--update-from-url"):
        os.system("python update.py --from-url " + sys.argv[2])
    elif ("--enable-auto-update" in sys.argv):
Exemple #4
0
def toBot(messageToBot):
    try:
        reload(bot)
        reload(learner)
        if (messageToBot == None):
            messageToBot = getSpeech()
        if (os.path.isfile(".bot_engage")):
            print("You can only run one instance of Clarissa.")
        else:
            swearNum = 1
            os.environ['CLARISSA_PATH'] = r.getClarissaSettingWithPath(
                "setup.ini", "main", "install")
            os.environ['USER_NAME'] = r.getClarissaSetting("main", "user.name")
            if (messageToBot == "--add-command"):
                writeCommand(command=input("Command: "),
                             response=input("Responses: "))
                reload(bot)
            elif (messageToBot == "kill-bot"):
                exit()
            elif (messageToBot == "--clear-commands"):
                #os.remove("commands.bot")
                #os.remove("responses.bot")]
                print("Cleared commands")
                exit()
            elif (messageToBot == "learn"):
                learner.learn(db_support=False)
            elif (messageToBot == "--get-commands"):
                commandsList = open("commands.list", "r")
                print(commandsList.read())
            elif (messageToBot == "--get-logs"):
                logs = open('chat.log', 'r')
                print(logs.read())
            elif (messageToBot == "--update-clarissa"):
                urllib.urlopen("https://softy.xyz/apps/sites/clarissa/get.php")
                response = urllib.request.urlopen(
                    "https://softy.xyz/apps/sites/clarissa/clarissa.json")
                import json
                file = json.loads(response.read())
                print(file['command'])
            elif (messageToBot == "list the commands"):
                file = open("commands.list", 'r')
                for line in file.readlines():
                    print("Clarissa: " + line)
            elif ("Call me " in messageToBot):
                w.setClarissaSetting("main", "user.name",
                                     messageToBot.replace("Call me ", ""))
            elif ("call me " in messageToBot):
                w.setClarissaSetting("main", "user.name",
                                     messageToBot.replace("call me ", ""))
            elif ("Run " in messageToBot):
                apps = Apps()
                if (apps.does_app_exist(messageToBot.replace("Run ",
                                                             "")) == True):
                    apps.run(messageToBot.replace("Run ", ""))
                    return None
                else:
                    print(messageToBot.replace("Run ", "") + " was not found")
                    if (clarissa_voice_recognition_enabled == True):
                        toBot(messageToBot=getSpeech())
                    else:
                        toBot(messageToBot=input(
                            r.getClarissaSetting("main", "user.name") + ": "))
            elif ("run " in messageToBot):
                apps = Apps()
                if (apps.does_app_exist(messageToBot.replace("run ",
                                                             "")) == True):
                    apps.run(messageToBot.replace("run ", ""))
                    return None
                else:
                    print(messageToBot.replace("run ", "") + " was not found")
                    if (clarissa_voice_recognition_enabled == True):
                        toBot(messageToBot=getSpeech())
                    else:
                        toBot(messageToBot=input(
                            r.getClarissaSetting("main", "user.name") + ": "))
            elif ("Make app" in messageToBot):
                apps = Apps()
                apps.make_app(input("App name:"))
            elif ("make app" in messageToBot):
                apps = Apps()
                apps.make_app(input("App name:"))

            log.log("chat.log", messageToBot)
            cpu_def = CPU()
            cpu_def.run_code(code=bot.getResponse(messageToBot))
            if (clarissa_voice_recognition_enabled == True):
                toBot(messageToBot=getSpeech())
            else:
                toBot(messageToBot=input(
                    r.getClarissaSetting("main", "user.name") + ": "))
    except TypeError:
        if (clarissa_voice_recognition_enabled is True):
            toBot(getSpeech())
        else:
            toBot(messageToBot=input(
                r.getClarissaSetting("main", "user.name") + ": "))
    except (KeyboardInterrupt, SystemExit):
        bot.getResponse("kill-bot")