diff --git a/plugins/coser/__init__.py b/plugins/coser/__init__.py index cb8c98ff..6bf55eed 100755 --- a/plugins/coser/__init__.py +++ b/plugins/coser/__init__.py @@ -36,7 +36,7 @@ __plugin_configs__ = { }, } -coser = on_regex(r"^(\d?)连?(cos|COS|coser|括丝)$", priority=5, block=True) +coser = on_regex(r"^(\d)?连?(cos|COS|coser|括丝)$", priority=5, block=True) # 纯cos,较慢:https://picture.yinux.workers.dev # 比较杂,有福利姬,较快:https://api.jrsgslb.cn/cos/url.php?return=img @@ -44,7 +44,7 @@ url = "https://picture.yinux.workers.dev/" @coser.handle() -async def _(bot: Bot, event: MessageEvent, reg_group: Tuple[Any, ...] = RegexGroup()): +async def _(event: MessageEvent, reg_group: Tuple[Any, ...] = RegexGroup()): num = reg_group[0] or 1 for _ in range(int(num)): try: diff --git a/plugins/quotations.py b/plugins/quotations.py index d3c5f96e..af4ee144 100755 --- a/plugins/quotations.py +++ b/plugins/quotations.py @@ -1,4 +1,4 @@ -from nonebot import on_command +from nonebot import on_regex from services.log import logger from nonebot.adapters.onebot.v11 import Bot, MessageEvent, GroupMessageEvent from nonebot.typing import T_State @@ -24,7 +24,7 @@ __plugin_settings__ = { } -quotations = on_command("语录", aliases={"二次元", "二次元语录"}, 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/_model.py b/plugins/word_bank/_model.py index 67ee7f27..c200c9c9 100644 --- a/plugins/word_bank/_model.py +++ b/plugins/word_bank/_model.py @@ -236,17 +236,19 @@ class WordBank(db.Model): # 完全匹配 if await query.where(cls.problem == problem).gino.first(): return query.where(cls.problem == problem) + # 模糊匹配 + if await query.where(cls.problem.contains(problem)).gino.first(): + return query.where(cls.problem.contains(problem)) # 正则匹配 if await db.first( db.text(sql_text + f" and word_type = 2 and word_scope != 999 and '{problem}' ~ problem;") ): return sql_text + f" and word_type = 2 and word_scope != 999 and '{problem}' ~ problem;" - # 模糊匹配 - if await db.first( - db.text(sql_text + f" and word_type = 1 and word_scope != 999 and '{problem}' ~ problem;") - ): - return sql_text + f" and word_type = 1 and word_scope != 999 and '{problem}' ~ problem;" - return None + # if await db.first( + # db.text(sql_text + f" and word_type = 1 and word_scope != 999 and '{problem}' ~ problem;") + # ): + # return sql_text + f" and word_type = 1 and word_scope != 999 and '{problem}' ~ problem;" + # return None @classmethod async def get_answer(