Little improvement

This commit is contained in:
Richard Chien
2017-01-03 01:06:11 +08:00
parent 882810378d
commit 1639bac368
3 changed files with 20 additions and 9 deletions

View File

@ -17,8 +17,8 @@ __registry__ = cr = CommandRegistry(init_func=_init)
@cr.register('process')
@cr.restrict(full_command_only=True)
def process(sentence, ctx_msg, internal=False):
sentence = sentence.strip()
def process(args_text, ctx_msg, internal=False):
sentence = args_text.strip()
potential_commands = parse_potential_commands(sentence)
potential_commands = sorted(filter(lambda x: x[0] > 60, potential_commands), key=lambda x: x[0], reverse=True)
if len(potential_commands) > 0:
@ -26,7 +26,13 @@ def process(sentence, ctx_msg, internal=False):
ctx_msg['parsed_data'] = most_possible_cmd[3]
cmdhub.call(most_possible_cmd[1], most_possible_cmd[2], ctx_msg)
else:
core.echo('我暂时不理解你在说什么哦~', ctx_msg, internal)
if ctx_msg.get('from_voice'):
core.echo('暂时无法理解你的意思,下面将发送图灵机器人的回复……', ctx_msg, internal)
core.tuling123(sentence, ctx_msg, internal)
else:
core.echo('暂时无法理解你的意思。\n'
'由于自然语言识别还非常不完善,建议使用命令来精确控制我。\n'
'如需帮助请发送「使用帮助」。', ctx_msg, internal)
def _load_processors():