mirror of
https://github.com/ChenXu233/nonebot_plugin_dialectlist.git
synced 2025-02-08 03:46:21 +08:00
✨ 私聊查询消息榜
This commit is contained in:
parent
6ba8ce9922
commit
5eb207fe16
@ -41,8 +41,6 @@ from nonebot_plugin_alconna import (
|
||||
)
|
||||
|
||||
from nonebot_plugin_chatrecorder import get_message_records
|
||||
from nonebot_plugin_localstore import get_cache_file
|
||||
from nonebot_plugin_htmlrender import html_to_pic
|
||||
from nonebot_plugin_userinfo import get_user_info
|
||||
from nonebot_plugin_session import Session, SessionIdType, extract_session
|
||||
|
||||
@ -61,6 +59,7 @@ from .utils import (
|
||||
msg_counter,
|
||||
persist_id2user_id,
|
||||
user_id2persist_id,
|
||||
group_id2persist_id,
|
||||
get_rank_image,
|
||||
)
|
||||
|
||||
@ -221,10 +220,9 @@ async def handle_rank(
|
||||
session: Session = Depends(extract_session),
|
||||
start: datetime = Arg(),
|
||||
stop: datetime = Arg(),
|
||||
# group_id: str = Arg(),
|
||||
):
|
||||
if id := state["group_id"]:
|
||||
# id = await user_id2persist_id(id)
|
||||
id = str(id)
|
||||
logger.debug(f"group_id: {id}")
|
||||
else:
|
||||
id = session.id2
|
||||
|
@ -67,15 +67,12 @@ async def user_id2persist_id(ids: List[str]) -> List[int]:
|
||||
|
||||
|
||||
async def group_id2persist_id(ids: List[str]) -> List[int]:
|
||||
whereclause: List[ColumnElement[bool]] = []
|
||||
whereclause.append(or_(*[SessionModel.id2 == id for id in ids]))
|
||||
statement = (
|
||||
select(SessionModel).where(*whereclause)
|
||||
# .join(SessionModel, SessionModel.id == MessageRecord.session_persist_id)
|
||||
)
|
||||
persist_ids = []
|
||||
async with get_session() as db_session:
|
||||
records = (await db_session.scalars(statement)).all()
|
||||
return [i.id for i in records]
|
||||
for i in ids:
|
||||
persist_id = (await db_session.scalar(select(SessionModel).where(or_(*[SessionModel.id2 == i])))).id # type: ignore
|
||||
persist_ids.append(persist_id)
|
||||
return persist_ids
|
||||
|
||||
|
||||
async def persist_id2group_id(ids: List[str]) -> List[str]:
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "nonebot-plugin-dialectlist"
|
||||
version = "2.1.9"
|
||||
version = "2.2.0"
|
||||
description = "看看你群群友有多能说"
|
||||
authors = [
|
||||
{name = "Chen_Xu233", email = "woyerpa@outlook.com"},
|
||||
|
Loading…
x
Reference in New Issue
Block a user