def get_bot_response(): userText = request.args.get('msg') checkCode = str(codecs.encode(bytes(userText, 'utf8'), 'base64')) checkCode = checkCode[2:18] if check == checkCode: print('Goodbye.') #Copy badBot.sqlite3 to botData.sqlite3 userText = 'Shutting down now...' file_directory = os.path.dirname(os.path.abspath('badBot.sqlite3')) bot_model_db = os.path.join(file_directory, "mybot/badBot.sqlite3") copyfile(bot_model_db, 'botData.sqlite3') file_directory = os.path.dirname(os.path.abspath('chatbot.csv')) bot_model_csv = os.path.join(file_directory, "mybot/data/chatbot.csv") if os.path.exists(bot_model_csv): os.remove(bot_model_csv) sys.exit() botReply = str(bot.get_response(userText)) if botReply == "IDKresponse": botReply = str(bot.get_response( 'IDKnull')) ##Send the i don't know code back to the DB if useGoogle == "yes": botReply = botReply + tryGoogle(userText) elif botReply == "getTIME": botReply = getTime() print(getTime()) elif botReply == "getDATE": botReply = getDate() print(getDate()) ##Log to CSV file print("Logging to CSV file now") with open('BotLog.csv', 'a', newline='') as logFile: newFileWriter = csv.writer(logFile) newFileWriter.writerow([userText, botReply]) logFile.close() return botReply
def get_bot_response(): userText = request.args.get('msg') botReply = str(bot.get_response(userText)) if botReply is "IDKresponse": botReply = str(bot.get_response('IDKnull')) ##Send the i don't know code back to the DB if useGoogle == "yes": botReply = botReply + tryGoogle(userText) elif botReply == "getTIME": botReply = getTime() print(getTime()) elif botReply == "getDATE": botReply = getDate() print(getDate()) return botReply
def get_bot_response(): userText = request.args.get('msg') botReply = str(bot.get_response(userText)) if botReply is "IDKresponse": botReply = str(bot.get_response('IDKnull')) ##Send the i don't know code back to the DB if useGoogle == "yes": botReply = botReply + tryGoogle(userText) elif botReply == "getTIME": botReply = getTime() print(getTime()) elif botReply == "getDATE": botReply = getDate() print(getDate()) ##Log to CSV file print("Logging to CSV file now") with open('BotLog.csv', 'a', newline='') as logFile: newFileWriter = csv.writer(logFile) newFileWriter.writerow([userText, botReply]) logFile.close() return botReply
def get_bot_response(): userText = str(request.args.get('msg')) botReply = str(bot.get_response(userText)) if botReply == "IDKresponse": if useGoogle == "yes": botReply = botReply + tryGoogle(userText) elif botReply == "getTIME": botReply = getTime() elif botReply == "getDATE": botReply = getDate() writeCsv(currentPath + "/log/botLog.csv", [userText, botReply]) data = {'botReply': botReply} return jsonify(data)