diff options
| author | Kyomotoi <37587870+Kyomotoi@users.noreply.github.com> | 2020-07-13 13:21:14 +0800 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-13 13:21:14 +0800 | 
| commit | fbbba78e84dc17fe91a14e83129756bad9f8e2aa (patch) | |
| tree | 0f4987904945063489a36955510badd004f0ef67 | |
| parent | 4e54e1c3b0bc9c6fa03ce5db4b23e132c47605a4 (diff) | |
| download | ATRI-fbbba78e84dc17fe91a14e83129756bad9f8e2aa.tar.gz ATRI-fbbba78e84dc17fe91a14e83129756bad9f8e2aa.tar.bz2 ATRI-fbbba78e84dc17fe91a14e83129756bad9f8e2aa.zip  | |
Update chat.py
| -rw-r--r-- | AyaBot/plugins/chat.py | 38 | 
1 files changed, 33 insertions, 5 deletions
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('恁哪位?')  | 
