🐛 修复缓存类型声明,优化封禁用户处理逻辑

This commit is contained in:
HibiKier 2025-05-11 23:11:08 +08:00
parent bb4dde7511
commit be85a03788
2 changed files with 4 additions and 4 deletions

View File

@ -29,15 +29,15 @@ Config.add_plugin_config(
async def is_ban(user_id: str | None, group_id: str | None) -> int:
if not user_id and not group_id:
return 0
cache = Cache[list[BanConsole]](CacheType.BAN)
cache = Cache[BanConsole](CacheType.BAN)
group_user, user = await asyncio.gather(
cache.get(user_id, group_id), cache.get(user_id)
)
results = []
if group_user:
results.extend(group_user)
results.append(group_user)
if user:
results.extend(user)
results.append(user)
if not results:
return 0
for result in results:

View File

@ -154,7 +154,7 @@ async def _():
return {f"{d.group_id or ''}:{d.user_id or ''}": d for d in data_list}
@CacheRoot.getter(CacheType.BAN, result_model=list[BanConsole])
@CacheRoot.getter(CacheType.BAN, result_model=BanConsole)
async def _(cache_data: CacheData, user_id: str | None, group_id: str | None = None):
"""获取封禁缓存"""
if not user_id and not group_id: