def run_bot(user_input, start):
"""
:param(str) user_input: Message sent to the bot
:param(bool) start: If the user is new to the bot
:return(str) return: Response from the bot
"""
if start:
bot.response = "Hello there! Have a chat with me or say 'help' to see available commands :)"
return bot.response
bot.user_input = user_input
# fix_typos: Fix any user typos and slang
# check_phrase_similarity: Check user's input similarity to all key phrases
# create_response: If all key phrases fail, we gotta actually make a new sentence
for method in ['fix_typos', 'help_check', 'check_phrase_similarity', 'create_response']:
if operator.methodcaller(method)(bot):
return bot.response
return random.choice(responses.UNSURE) # If no response can be created
# For testing purposes
评论列表
文章目录