Skip to content

feat: 添加群管理分析工具集#25

Merged
69gg merged 2 commits intomainfrom
feature/group-manager
Feb 12, 2026
Merged

feat: 添加群管理分析工具集#25
69gg merged 2 commits intomainfrom
feature/group-manager

Conversation

@69gg
Copy link
Owner

@69gg 69gg commented Feb 12, 2026

功能概述

新增三个群管理分析工具,用于深度分析群成员活跃度和加群情况。

新增工具

1. analyze_member_messages - 成员消息分析

  • 统计指定成员在时间段内的消息数量
  • 分析消息类型分布(文本、图片、表情、回复等)
  • 分析活跃时段(最活跃的小时、星期)
  • 可选返回具体消息内容

2. analyze_join_statistics - 加群统计分析

  • 统计指定时间段内的加群人数
  • 分析每日加群趋势
  • 找出加群高峰期
  • 可选返回新成员列表

3. analyze_new_member_activity - 新成员活跃度分析

  • 统计新成员的活跃率
  • 找出最活跃的新成员(排行榜)
  • 计算人均发言数
  • 识别未发言的新成员

技术实现

新增共享工具函数:

  • time_utils.py: 时间解析工具
  • message_utils.py: 消息处理工具(获取、筛选、统计、格式化)
  • member_utils.py: 成员处理工具(筛选、趋势分析、活跃度分析)

代码质量

  • ✅ 所有代码通过 ruff format 格式化
  • ✅ 所有代码通过 ruff check 检查
  • ✅ 所有代码通过 mypy 类型检查
  • ✅ 使用完整的类型注释
  • ✅ 包含详细的文档字符串

使用场景

  • 评估群运营效果
  • 了解成员活跃情况
  • 分析新成员融入程度
  • 识别需要关注的成员

新增三个群管理分析工具:
- analyze_member_messages: 成员消息分析(消息统计、类型分布、活跃度)
- analyze_join_statistics: 加群统计分析(人数统计、趋势分析)
- analyze_new_member_activity: 新成员活跃度分析(活跃率、排行榜)

新增共享工具函数:
- time_utils.py: 时间解析工具
- message_utils.py: 消息处理工具
- member_utils.py: 成员处理工具

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3fc46248d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 26 to 27

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate numeric limits before applying min()

These limits are used before any type/range validation, so schema-valid but negative values (for example message_limit=-1 or max_history_count=-1) produce incorrect behavior (user_messages[:-1] returns almost all messages, while a negative history count skips fetching entirely), and non-integer values like null/string can raise a TypeError before the handler’s try block. This turns a recoverable bad argument into misleading results or a generic execution error; clamp to non-negative ints (and coerce/validate) before using them. The same pattern is also present in the other new group_analysis handlers.

Useful? React with 👍 / 👎.

修复问题:
- 在使用参数之前添加类型和范围验证
- 防止负数参数导致的错误行为(如 message_limit=-1)
- 防止非整数参数导致的 TypeError
- 提供清晰的错误消息

影响的工具:
- analyze_member_messages
- analyze_join_statistics
- analyze_new_member_activity

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@69gg 69gg merged commit ead2ff9 into main Feb 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments