mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-26 12:55:06 +08:00
✨ 消息统计新增指定用户选项
This commit is contained in:
parent
8e06244311
commit
5bc2725d1b
@ -22,7 +22,7 @@ async def count_msg_by_bot_id(bot_id: str) -> int:
|
|||||||
return len(msg_rows)
|
return len(msg_rows)
|
||||||
|
|
||||||
|
|
||||||
async def get_stat_msg_image(duration: int, period: int, group_id: str = None, bot_id: str = None,
|
async def get_stat_msg_image(duration: int, period: int, group_id: str = None, bot_id: str = None, user_id: str = None,
|
||||||
ulang: Language = Language()) -> bytes:
|
ulang: Language = Language()) -> bytes:
|
||||||
"""
|
"""
|
||||||
获取统计消息
|
获取统计消息
|
||||||
@ -50,6 +50,10 @@ async def get_stat_msg_image(duration: int, period: int, group_id: str = None, b
|
|||||||
condition += " AND bot_id = ?"
|
condition += " AND bot_id = ?"
|
||||||
condition_args.append(bot_id)
|
condition_args.append(bot_id)
|
||||||
|
|
||||||
|
if user_id:
|
||||||
|
condition += " AND user_id = ?"
|
||||||
|
condition_args.append(user_id)
|
||||||
|
|
||||||
msg_rows = msg_db.where_all(
|
msg_rows = msg_db.where_all(
|
||||||
MessageEventModel(),
|
MessageEventModel(),
|
||||||
condition,
|
condition,
|
||||||
|
@ -35,6 +35,11 @@ stat_msg = on_alconna(
|
|||||||
Args["group_id", str, "current"],
|
Args["group_id", str, "current"],
|
||||||
help_text="指定群组"
|
help_text="指定群组"
|
||||||
),
|
),
|
||||||
|
Option(
|
||||||
|
"-u|--user",
|
||||||
|
Args["user_id", str, "current"],
|
||||||
|
help_text="指定用户"
|
||||||
|
),
|
||||||
alias={"msg", "m"},
|
alias={"msg", "m"},
|
||||||
help_text="查看统计次数内的消息"
|
help_text="查看统计次数内的消息"
|
||||||
)
|
)
|
||||||
@ -56,6 +61,7 @@ async def _(result: Arparma, event: T_MessageEvent, bot: Bot):
|
|||||||
|
|
||||||
group_id = result.other_args.get("group_id")
|
group_id = result.other_args.get("group_id")
|
||||||
bot_id = result.other_args.get("bot_id")
|
bot_id = result.other_args.get("bot_id")
|
||||||
|
user_id = result.other_args.get("user_id")
|
||||||
|
|
||||||
if group_id in ["current", "c"]:
|
if group_id in ["current", "c"]:
|
||||||
group_id = str(event_utils.get_group_id(event))
|
group_id = str(event_utils.get_group_id(event))
|
||||||
@ -66,5 +72,8 @@ async def _(result: Arparma, event: T_MessageEvent, bot: Bot):
|
|||||||
if bot_id in ["current", "c"]:
|
if bot_id in ["current", "c"]:
|
||||||
bot_id = str(bot.self_id)
|
bot_id = str(bot.self_id)
|
||||||
|
|
||||||
img = await get_stat_msg_image(duration, period, group_id, bot_id, ulang)
|
if user_id in ["current", "c"]:
|
||||||
|
user_id = str(event_utils.get_user_id(event))
|
||||||
|
|
||||||
|
img = await get_stat_msg_image(duration=duration, period=period, group_id=group_id, bot_id=bot_id, user_id=user_id, ulang=ulang)
|
||||||
await stat_msg.send(UniMessage.image(raw=img))
|
await stat_msg.send(UniMessage.image(raw=img))
|
||||||
|
Loading…
Reference in New Issue
Block a user