mirror of
https://github.com/cdryzun/tg_bot_collections.git
synced 2025-08-05 21:56:44 +08:00
feat: get user stats in the group
Signed-off-by: Keming <kemingy94@gmail.com>
This commit is contained in:
@ -94,6 +94,23 @@ def stats_command(message: Message, bot: TeleBot):
|
||||
)
|
||||
|
||||
|
||||
@non_llm_handler
|
||||
def user_stats_command(message: Message, bot: TeleBot):
|
||||
"""看看谁才是最能摸鱼的"""
|
||||
user_stats = store.get_user_stats(message.chat.id)
|
||||
if not user_stats:
|
||||
bot.reply_to(message, "没有找到任何用户统计信息。")
|
||||
return
|
||||
user_stats_text = "\n".join(
|
||||
f"{entry.user_name}: {entry.message_count}" for entry in user_stats
|
||||
)
|
||||
bot.reply_to(
|
||||
message,
|
||||
f"👤 用户消息统计信息:\n```\n{user_stats_text}\n```",
|
||||
parse_mode="MarkdownV2",
|
||||
)
|
||||
|
||||
|
||||
@non_llm_handler
|
||||
def search_command(message: Message, bot: TeleBot):
|
||||
"""搜索群组消息(示例:/search 关键词 [N])"""
|
||||
@ -134,6 +151,9 @@ if settings.openai_api_key:
|
||||
summary_command, commands=["summary"], pass_bot=True
|
||||
)
|
||||
bot.register_message_handler(stats_command, commands=["stats"], pass_bot=True)
|
||||
bot.register_message_handler(
|
||||
user_stats_command, commands=["userstats"], pass_bot=True
|
||||
)
|
||||
bot.register_message_handler(search_command, commands=["search"], pass_bot=True)
|
||||
bot.register_message_handler(
|
||||
handle_message, func=partial(filter_message, bot=bot)
|
||||
|
Reference in New Issue
Block a user