summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2022-07-17 21:20:23 +0800
committerKyomotoi <[email protected]>2022-07-17 21:20:23 +0800
commit8b0111a6e23745f6c51e2037564a2c8972bf84e9 (patch)
tree81111c60eb4e02c03e1d7b4c48d6eafda2d2137e
parenta24d040bfa2e2c6340f31548059af7ccd144a15d (diff)
downloadATRI-8b0111a6e23745f6c51e2037564a2c8972bf84e9.tar.gz
ATRI-8b0111a6e23745f6c51e2037564a2c8972bf84e9.tar.bz2
ATRI-8b0111a6e23745f6c51e2037564a2c8972bf84e9.zip
🚑️ 修复词库匹配bug
-rw-r--r--ATRI/plugins/thesaurus/listener.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/ATRI/plugins/thesaurus/listener.py b/ATRI/plugins/thesaurus/listener.py
index a05965c..5cf0baa 100644
--- a/ATRI/plugins/thesaurus/listener.py
+++ b/ATRI/plugins/thesaurus/listener.py
@@ -127,3 +127,44 @@ async def _tl_listener(event: MessageEvent):
return
else:
await main_listener.finish(Message(choice(item_info.result)))
+
+ query_result = await tl.get_item_list(int())
+ if not query_result:
+ return
+
+ shuffle(query_result)
+
+ for item in query_result:
+ item_info: ThesaurusStoragor = item
+
+ if not item_info.result:
+ continue
+
+ if item_info.m_type == 1:
+ if item_info.matcher in msg:
+ if item_info.need_at:
+ if event.is_tome():
+ await main_listener.finish(Message(choice(item_info.result)))
+ else:
+ return
+ else:
+ await main_listener.finish(Message(choice(item_info.result)))
+ elif item_info.m_type == 2:
+ patt = item_info.matcher
+ if re.findall(patt, msg):
+ if item_info.need_at:
+ if event.is_tome():
+ await main_listener.finish(Message(choice(item_info.result)))
+ else:
+ return
+ else:
+ await main_listener.finish(Message(choice(item_info.result)))
+ else:
+ if item_info.matcher == msg:
+ if item_info.need_at:
+ if event.is_tome():
+ await main_listener.finish(Message(choice(item_info.result)))
+ else:
+ return
+ else:
+ await main_listener.finish(Message(choice(item_info.result)))