🚑 移除认证队列机制并放宽消息记录规则 (#2091)

* 🚑 fix(auth_hook):直接调用 auth 并移除认证队列

* 🚑 fix(chat_message): 简化规则函数,移除不必要的命令检查和时间间隔逻辑

---------

Co-authored-by: ATTomatoo <1126160939@qq.com>
This commit is contained in:
ManyManyTomato
2026-02-04 10:46:44 +08:00
committed by GitHub
co-authored by ATTomatoo
parent 8378921c71
commit 662d61a672
2 changed files with 21 additions and 77 deletions
@@ -1,8 +1,7 @@
import asyncio
import time
from nonebot import get_driver, on_message
from nonebot.adapters import Event
from nonebot import on_message
from nonebot.plugin import PluginMetadata
from nonebot_plugin_alconna import UniMsg
from nonebot_plugin_apscheduler import scheduler
@@ -38,43 +37,8 @@ __plugin_meta__ = PluginMetadata(
)
_COMMAND_STARTS = {str(item) for item in (get_driver().config.command_start or [])}
_LAST_GROUP_SAVE: dict[str, float] = {}
_LAST_USER_SAVE: dict[str, float] = {}
_GROUP_MIN_INTERVAL = 0.5
_USER_MIN_INTERVAL = 0.2
def _is_command_like(text: str) -> bool:
if not text:
return False
for start in _COMMAND_STARTS:
if text.startswith(start):
return True
return False
async def rule(event: Event, message: UniMsg, session: Uninfo) -> bool:
if is_overloaded():
return False
if not Config.get_config("chat_history", "FLAG"):
return False
if not message:
return False
text = message.extract_plain_text().strip()
if _is_command_like(text):
return False
entity = get_entity_ids(session)
now = time.time()
if entity.group_id:
last_group = _LAST_GROUP_SAVE.get(entity.group_id, 0)
if now - last_group < _GROUP_MIN_INTERVAL:
return False
if entity.user_id:
last_user = _LAST_USER_SAVE.get(entity.user_id, 0)
if now - last_user < _USER_MIN_INTERVAL:
return False
return True
def rule(message: UniMsg) -> bool:
return bool(Config.get_config("chat_history", "FLAG") and message)
chat_history = on_message(rule=rule, priority=1, block=False)
@@ -89,10 +53,6 @@ _DROP_LOG_INTERVAL = 10.0
async def _(message: UniMsg, session: Uninfo):
entity = get_entity_ids(session)
now = time.time()
if entity.group_id:
_LAST_GROUP_SAVE[entity.group_id] = now
if entity.user_id:
_LAST_USER_SAVE[entity.user_id] = now
if is_overloaded():
return
try: