Fix bug that when someone add xiaokai on wechat

This commit is contained in:
Richard Chien 2017-01-03 12:08:56 +08:00
parent 276211bf5e
commit 3a116b9bc9
2 changed files with 10 additions and 4 deletions

View File

@ -46,7 +46,7 @@ def tuling123(args_text, ctx_msg, internal=False):
@cr.register('help', '帮助', '用法', '使用帮助', '使用指南', '使用说明', '使用方法', '怎么用') @cr.register('help', '帮助', '用法', '使用帮助', '使用指南', '使用说明', '使用方法', '怎么用')
def help(_, ctx_msg): def help(_, ctx_msg):
echo( echo(
'你好!我是 CCZU 小开机器人,由常州大学开发者协会开发。\n' '你好%s!我是 CCZU 小开机器人,由常州大学开发者协会开发。\n'
'我可以为你做一些简单的事情,如发送知乎日报内容、翻译一段文字等。\n' '我可以为你做一些简单的事情,如发送知乎日报内容、翻译一段文字等。\n'
'下面是我现在能做的一些事情:\n\n' '下面是我现在能做的一些事情:\n\n'
'(1)/查天气 常州\n' '(1)/查天气 常州\n'
@ -61,6 +61,6 @@ def help(_, ctx_msg):
'(10)/聊天 你好啊\n\n' '(10)/聊天 你好啊\n\n'
'把以上内容之一(包括斜杠,不包括序号,某些部分替换成你需要的内容)发给我,我就会按你的要求去做啦。\n' '把以上内容之一(包括斜杠,不包括序号,某些部分替换成你需要的内容)发给我,我就会按你的要求去做啦。\n'
'上面只给出了 10 条功能,还有更多功能和使用方法,请查看 http://t.cn/RIr177e\n\n' '上面只给出了 10 条功能,还有更多功能和使用方法,请查看 http://t.cn/RIr177e\n\n'
'祝你使用愉快~', '祝你使用愉快~' % ('' + ctx_msg.get('sender') if ctx_msg.get('sender') else ''),
ctx_msg ctx_msg
) )

View File

@ -1,14 +1,20 @@
import re
from filter import as_filter from filter import as_filter
from commands import core from commands import core
@as_filter(priority=1) @as_filter(priority=1)
def _print_help_message(ctx_msg): def _print_help_message(ctx_msg):
a = ['help', '怎么用', '怎么用啊', '你好', '你好啊', '帮助', a = ['help', '怎么用', '怎么用啊', '你好', '你好啊', '你好呀', '帮助',
'用法', '使用帮助', '使用指南', '使用说明', '使用方法', '用法', '使用帮助', '使用指南', '使用说明', '使用方法',
'你能做什么', '你能做些什么', '你会做什么', '你会做些什么', '你能做什么', '你能做些什么', '你会做什么', '你会做些什么',
'你可以做什么', '你可以做些什么'] '你可以做什么', '你可以做些什么']
if ctx_msg.get('text', '').strip() in a: text = ctx_msg.get('text', '').strip()
sender = ctx_msg.get('sender', '')
if text in a or re.match('^' + sender + '刚刚把你添加到通讯录,现在可以开始聊天了。$', text):
core.help('', ctx_msg) core.help('', ctx_msg)
return False return False
elif re.match('^你已添加了' + sender + ',现在可以开始聊天了。$', text):
return False
return True return True