示例#1
0
 def command_process(command_str):
     if command_str:
         answer = will.main(command_str)
         answer_json = json.loads(answer)
         answer_text = answer_json["text"]
         answer_type = answer_json["return_type"]
         answer_action = answer_json["return_action"]
         if answer_type == "answer":
             easygui.msgbox(title="W.I.L.L", msg=answer_text)
             command()
         else:
             def enter_response():
                 response_text = easygui.enterbox(title="W.I.L.L", msg=answer_text)
                 if response_text:
                     response = {}
                     response.update({"response_args":response_text,"response_type":answer_type, "return_action":answer_action})
                     for key in answer_json.keys():
                         if not response[key]:
                             response.update({key:answer_json[key]})
                     new_answer = will.main(response)
                     command_process(new_answer)
                 else:
                     if easygui.ynbox(title="W.I.L.L", msg="Would you like to exit?"):
                         sys.exit()
                     else:
                         enter_response()
             enter_response()
     else:
         if easygui.ynbox(title="W.I.L.L",msg="Would you like to exit?"):
             sys.exit()
         else:
             command()
示例#2
0
 def command_process(command_str):
     if command_str:
         answer = will.main(command_str)
         answer_json = json.loads(answer)
         answer_text = answer_json["text"]
         answer_type = answer_json["return_type"]
         answer_action = answer_json["return_action"]
         if answer_type == "answer":
             print answer_text
             command()
         else:
             def enter_response():
                 response_text = raw_input(answer_text)
                 if response_text:
                     response = {}
                     response.update({"response_args":response_text,"response_type":answer_type, "return_action":answer_action})
                     for key in answer_json.keys():
                         if not response[key]:
                             response.update({key:answer_json[key]})
                     new_answer = will.main(response)
                     command_process(new_answer)
                 else:
                     if raw_input("Would you like to exit? (y/n)").lower() == "y":
                         sys.exit()
                     else:
                         enter_response()
             enter_response()
     else:
         if raw_input("Would you like to exit? (y/n)").lower() == "y":
             sys.exit()
         else:
             command()
示例#3
0
 def enter_response():
     response_text = easygui.enterbox(title="W.I.L.L", msg=answer_text)
     if response_text:
         response = {}
         response.update({"response_args":response_text,"response_type":answer_type, "return_action":answer_action})
         for key in answer_json.keys():
             if not response[key]:
                 response.update({key:answer_json[key]})
         new_answer = will.main(response)
         command_process(new_answer)
     else:
         if easygui.ynbox(title="W.I.L.L", msg="Would you like to exit?"):
             sys.exit()
         else:
             enter_response()
示例#4
0
 def enter_response():
     response_text = raw_input(answer_text)
     if response_text:
         response = {}
         response.update({"response_args":response_text,"response_type":answer_type, "return_action":answer_action})
         for key in answer_json.keys():
             if not response[key]:
                 response.update({key:answer_json[key]})
         new_answer = will.main(response)
         command_process(new_answer)
     else:
         if raw_input("Would you like to exit? (y/n)").lower() == "y":
             sys.exit()
         else:
             enter_response()
示例#5
0
def command(message):
    '''Setup basic information and get started'''
    log.info("In setup with message {0}".format(str(message)))
    if user_check(message):
        command = message.text
        log.info("Command is {0}".format(str(command)))
        answer = will.main(str(command))
        log.info("Answer is {0}".format(str(answer)))
        answer_json = json.loads(answer)
        answer_text = answer_json["text"]
        log.info("Answer text is {0}".format(answer_text))
        answer_type = answer_json["return_type"]
        log.info("Answer type is {0}".format(answer_type))
        if answer_type == "text":
            log.info("Answer type is text, responding with {1}".format(str(answer_text)))
            bot.reply_to(message, answer_text)
        else:
            return_message = bot.reply_to(message, answer_text)
            bot.register_next_step_handler(return_message, answer_json)
示例#6
0
 def enter_response():
     response_text = raw_input(answer_text)
     if response_text:
         response = {}
         response.update({
             "response_args": response_text,
             "response_type": answer_type,
             "return_action": answer_action
         })
         for key in answer_json.keys():
             if not response[key]:
                 response.update({key: answer_json[key]})
         new_answer = will.main(response)
         command_process(new_answer)
     else:
         if raw_input("Would you like to exit? (y/n)").lower(
         ) == "y":
             sys.exit()
         else:
             enter_response()
示例#7
0
 def enter_response():
     response_text = easygui.enterbox(title="W.I.L.L",
                                      msg=answer_text)
     if response_text:
         response = {}
         response.update({
             "response_args": response_text,
             "response_type": answer_type,
             "return_action": answer_action
         })
         for key in answer_json.keys():
             if not response[key]:
                 response.update({key: answer_json[key]})
         new_answer = will.main(response)
         command_process(new_answer)
     else:
         if easygui.ynbox(title="W.I.L.L",
                          msg="Would you like to exit?"):
             sys.exit()
         else:
             enter_response()
示例#8
0
def action_return(message, answer_json):
    response = {}
    answer_action = answer_json["return_action"]
    answer_type = answer_json["return_type"]
    response.update({"response_args": message.teext, "response_type": answer_type, "return_action": answer_action})
    for key in answer_json.keys():
        if not response[key]:
            response.update({key: answer_json[key]})
    returned = will.main(response)
    log.info("Returned is {0}".format(str(returned)))
    return_json = json.loads(returned)
    return_type = return_json["return_type"]
    log.info("Return type is {0}".format(return_type))
    return_text = answer_json["text"]
    log.info("Return text is {0}".format(return_text))
    if return_type == "text":
        log.info("Return type is text, returning {0}".format(str(return_text)))
        bot.reply_to(message, return_text)
    else:
        return_message = bot.reply_to(message, return_text)
        bot.register_next_step_handler(return_message, return_json)
示例#9
0
    def command_process(command_str):
        if command_str:
            answer = will.main(command_str)
            answer_json = json.loads(answer)
            answer_text = answer_json["text"]
            answer_type = answer_json["return_type"]
            answer_action = answer_json["return_action"]
            if answer_type == "answer":
                easygui.msgbox(title="W.I.L.L", msg=answer_text)
                command()
            else:

                def enter_response():
                    response_text = easygui.enterbox(title="W.I.L.L",
                                                     msg=answer_text)
                    if response_text:
                        response = {}
                        response.update({
                            "response_args": response_text,
                            "response_type": answer_type,
                            "return_action": answer_action
                        })
                        for key in answer_json.keys():
                            if not response[key]:
                                response.update({key: answer_json[key]})
                        new_answer = will.main(response)
                        command_process(new_answer)
                    else:
                        if easygui.ynbox(title="W.I.L.L",
                                         msg="Would you like to exit?"):
                            sys.exit()
                        else:
                            enter_response()

                enter_response()
        else:
            if easygui.ynbox(title="W.I.L.L", msg="Would you like to exit?"):
                sys.exit()
            else:
                command()
示例#10
0
    def command_process(command_str):
        if command_str:
            answer = will.main(command_str)
            answer_json = json.loads(answer)
            answer_text = answer_json["text"]
            answer_type = answer_json["return_type"]
            answer_action = answer_json["return_action"]
            if answer_type == "answer":
                print answer_text
                command()
            else:

                def enter_response():
                    response_text = raw_input(answer_text)
                    if response_text:
                        response = {}
                        response.update({
                            "response_args": response_text,
                            "response_type": answer_type,
                            "return_action": answer_action
                        })
                        for key in answer_json.keys():
                            if not response[key]:
                                response.update({key: answer_json[key]})
                        new_answer = will.main(response)
                        command_process(new_answer)
                    else:
                        if raw_input("Would you like to exit? (y/n)").lower(
                        ) == "y":
                            sys.exit()
                        else:
                            enter_response()

                enter_response()
        else:
            if raw_input("Would you like to exit? (y/n)").lower() == "y":
                sys.exit()
            else:
                command()