From 1e57ddb9ee8d655d82dff6ad0bb861ffe711fa3c Mon Sep 17 00:00:00 2001 From: Cinte Date: Mon, 22 Aug 2022 11:14:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86at=E5=90=8E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=8E=A5=E7=A9=BA=E6=A0=BC=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=8C?= =?UTF-8?q?problem=E4=B8=AD=E5=85=81=E8=AE=B8=E5=8D=95=E7=A9=BA=E7=99=BD?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E5=8F=B7=20&=20=E4=BF=AE=E5=A4=8D=E4=BA=8C?= =?UTF-8?q?=E6=AC=A1=E5=85=83=E8=A7=A6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/quotations.py | 2 +- plugins/word_bank/word_handle.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/quotations.py b/plugins/quotations.py index af4ee144..85fd3d9c 100755 --- a/plugins/quotations.py +++ b/plugins/quotations.py @@ -24,7 +24,7 @@ __plugin_settings__ = { } -quotations = on_regex("^[语录|二次元]$", priority=5, block=True) +quotations = on_regex("^(语录|二次元)$", priority=5, block=True) url = "https://international.v1.hitokoto.cn/?c=a" diff --git a/plugins/word_bank/word_handle.py b/plugins/word_bank/word_handle.py index 8802a2f0..7356d66b 100644 --- a/plugins/word_bank/word_handle.py +++ b/plugins/word_bank/word_handle.py @@ -25,7 +25,7 @@ usage: 更推荐使用id方式删除 问题回答支持的CQ:at, face, image 查看词条命令:群聊时为 群词条+全局词条,私聊时为 私聊词条+全局词条 - 添加词条正则:添加词条(模糊|正则|图片)?问\s*?(\S*)\s*?答\s?(\S*) + 添加词条正则:添加词条(模糊|正则|图片)?问\s*?(\S*\s?\S*)\s*?答\s?(\S*) 指令: 添加词条 ?[模糊|正则|图片]问...答...:添加问答词条,可重复添加相同问题的不同回答 删除词条 [问题/下标] ?[下标]:删除指定词条指定或全部回答 @@ -49,7 +49,7 @@ __plugin_superuser_usage__ = r""" usage: 在私聊中超级用户额外设置 指令: - (全局|私聊)?添加词条\s*?(模糊|正则|图片)?问\s*?(\S*)\s*?答\s?(\S*):添加问答词条,可重复添加相同问题的不同回答 + (全局|私聊)?添加词条\s*?(模糊|正则|图片)?问\s*?(\S*\s?\S*)\s*?答\s?(\S*):添加问答词条,可重复添加相同问题的不同回答 全局添加词条 私聊添加词条 (私聊情况下)删除词条: 删除私聊词条 @@ -76,7 +76,7 @@ data_dir = DATA_PATH / "word_bank" data_dir.mkdir(parents=True, exist_ok=True) add_word = on_regex( - r"^(全局|私聊)?添加词条\s*?(模糊|正则|图片)?问\s*?(\S*)\s*?答\s?(\S*)", priority=5, block=True + r"^(全局|私聊)?添加词条\s*?(模糊|正则|图片)?问\s*?(\S*\s?\S*)\s*?答\s?(\S*)", priority=5, block=True ) delete_word_matcher = on_command("删除词条", aliases={'删除全局词条'}, priority=5, block=True) @@ -117,7 +117,10 @@ async def _( answer = event.message[index:] answer[0] = str(answer[0])[str(answer[0]).index('答')+1:] _problem[0] = str(_problem[0])[str(_problem[0]).index('问')+1:] - _problem.append(seg.data['text'][:seg.data['text'].index('答')]) + if _problem[-1].type == 'at' and seg.data['text'][:seg.data['text'].index('答')].lstrip(): + _problem.append(seg.data['text'][:seg.data['text'].index('答')]) + else: + _problem.append(seg.data['text'][:seg.data['text'].index('答')].lstrip()) temp = '' for g in _problem: if isinstance(g, str):