From fbbba78e84dc17fe91a14e83129756bad9f8e2aa Mon Sep 17 00:00:00 2001 From: Kyomotoi <37587870+Kyomotoi@users.noreply.github.com> Date: Mon, 13 Jul 2020 13:21:14 +0800 Subject: Update chat.py --- AyaBot/plugins/chat.py | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'AyaBot/plugins') diff --git a/AyaBot/plugins/chat.py b/AyaBot/plugins/chat.py index 33d4291..8227052 100644 --- a/AyaBot/plugins/chat.py +++ b/AyaBot/plugins/chat.py @@ -70,11 +70,39 @@ class Chat(object): @on_command('chat') async def chat(session: CommandSession): - msg = session.state.get('msg') - reply = await Chat.request(msg) - await session.finish(reply) - return + if chat_switch: + msg = session.state.get('msg') + reply = await Chat.request(msg) + await session.finish(reply) + return + else: + await session.send('えつ,アトリ被主人告知不能与陌生人说话') @on_natural_language async def _(session: NLPSession): - return IntentCommand(60.0, ('chat'), {'msg': session.msg_text}) \ No newline at end of file + return IntentCommand(60.0, ('chat'), {'msg': session.msg_text}) + +chat_switch = True +@on_command('chat_switch', aliases=['开启', '关闭'], only_to_me=False) +async def _(session: CommandSession): + if session.event.user_id in master: + command = session.event.raw_message.split(' ', 1) + switch = command[0] + com = command[1] + global chat_switch + if switch == '开启': + if com == '闲聊': + chat_switch = True + else: + pass + + elif switch == '关闭': + if com == '闲聊': + chat_switch = False + else: + pass + + await session.send('完成') + + else: + await session.send('恁哪位?') -- cgit v1.2.3