Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

让引用回复、发送表情包操作计时合理 #634

Merged
merged 5 commits into from
Apr 3, 2025

Conversation

Dax233
Copy link
Contributor

@Dax233 Dax233 commented Apr 2, 2025

  • 🔴当前项目处于重构阶段(2025.3.14-)
  • ✅ 接受:与main直接相关的Bug修复:提交到main-fix分支
  • ⚠️ 冻结:所有新功能开发和非紧急重构

请填写以下内容

(删除掉中括号内的空格,并替换为小写的x

    • main 分支 禁止修改,请确认本次提交的分支 不是 main 分支
    • 本次更新 包含破坏性变更(如数据库结构变更、配置文件修改等)
    • 本次更新是否经过测试
    • 不要在数据库中添加group_id字段,这会影响本项目对其他平台的兼容
  1. 请填写破坏性更新的具体内容(如有):
  2. 请简要说明本次更新的内容和目的:
    用正则替换掉引用内容和表情包描述,改为随机增加一小段计时,模拟找表情包和爬楼引用的时间。

其他信息

Sourcery 总结

修改打字时间计算,以包含引用回复和表情符号/图像操作的模拟时间

Bug 修复:

  • 重构字符类型检查,使用更通用的方法来识别非西方字符

增强功能:

  • 为引用回复和表情符号/图像操作添加随机时间延迟,以模拟更真实的打字行为
Original summary in English

Summary by Sourcery

Modify typing time calculation to include simulated time for reference replies and emoji/image operations

Bug Fixes:

  • Refactor character type checking to use a more generalized method for identifying non-Western characters

Enhancements:

  • Add random time delay for reference replies and emoji/image operations to simulate more realistic typing behavior

Copy link
Contributor

sourcery-ai bot commented Apr 2, 2025

## Sourcery 评审者指南

此 Pull Request 引入了输入时间计算的延迟,以模拟查找和插入回复、图像或表情符号所需的时间。它通过使用正则表达式识别输入字符串中的这些元素并添加随机延迟来实现这一点。字符计数逻辑也被重构为使用 `is_western_char`。

#### 添加了回复/表情符号延迟的输入时间计算时序图

```mermaid
sequenceDiagram
    participant User
    participant ChatBot
    participant TypingTimeCalculator

    User->>ChatBot: 发送带有回复/表情符号的消息
    ChatBot->>TypingTimeCalculator: calculate_typing_time(message)
    TypingTimeCalculator->>TypingTimeCalculator: 使用正则表达式识别回复/表情符号
    alt 找到回复/表情符号
        TypingTimeCalculator->>TypingTimeCalculator: 添加随机延迟(1-3 秒)
    end
    TypingTimeCalculator->>TypingTimeCalculator: 根据字符计算输入时间
    TypingTimeCalculator-->>ChatBot: 输入时间
    ChatBot->>ChatBot: 模拟输入
    ChatBot-->>User: 发送响应

文件级别变更

变更 详情 文件
添加了随机延迟,以模拟查找和插入回复、图像或表情符号所花费的时间。
  • 添加了一个正则表达式来匹配回复引用和图像/表情符号描述。
  • 如果找到匹配项,则从输入字符串中删除匹配的文本。
  • 在总时间上增加 1 到 3 秒之间的随机时间。
  • 重构了字符计数逻辑,使用 is_western_char 而不是 unicode 范围。
src/plugins/chat/utils.py

可能相关的 issue

  • #0: 此 PR 通过从时间计算中排除图像/引用描述并添加少量随机时间来修复此问题。

提示和命令

与 Sourcery 交互

  • 触发新的审查: 在 pull request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 通过回复审查评论,要求 Sourcery 从审查评论创建一个 issue。您也可以回复审查评论并使用 @sourcery-ai issue 从中创建一个 issue。
  • 生成 pull request 标题: 在 pull request 标题中的任何位置写入 @sourcery-ai 以随时生成标题。您也可以在 pull request 上评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中的任何位置写入 @sourcery-ai summary 以随时在您想要的位置生成 PR 摘要。您也可以在 pull request 上评论 @sourcery-ai summary 以随时(重新)生成摘要。
  • 生成评审者指南: 在 pull request 上评论 @sourcery-ai guide 以随时(重新)生成评审者指南。
  • 解决所有 Sourcery 评论: 在 pull request 上评论 @sourcery-ai resolve 以解决所有 Sourcery 评论。如果您已经解决了所有评论并且不想再看到它们,这将非常有用。
  • 驳回所有 Sourcery 审查: 在 pull request 上评论 @sourcery-ai dismiss 以驳回所有现有的 Sourcery 审查。如果您想重新开始新的审查,这将特别有用 - 不要忘记评论 @sourcery-ai review 以触发新的审查!
  • 为 issue 生成行动计划: 在 issue 上评论 @sourcery-ai plan 以生成行动计划。

自定义您的体验

访问您的 仪表板 以:

  • 启用或禁用审查功能,例如 Sourcery 生成的 pull request 摘要、评审者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获得帮助

```
Original review guide in English

Reviewer's Guide by Sourcery

This pull request introduces a delay to the typing time calculation to simulate the time it takes to find and insert replies, images, or emoticons. It achieves this by using regular expressions to identify these elements in the input string and adding a random delay. The character counting logic was also refactored to use is_western_char.

Sequence diagram for calculating typing time with added delay for replies/emojis

sequenceDiagram
    participant User
    participant ChatBot
    participant TypingTimeCalculator

    User->>ChatBot: Sends message with reply/emoji
    ChatBot->>TypingTimeCalculator: calculate_typing_time(message)
    TypingTimeCalculator->>TypingTimeCalculator: Identify reply/emoji using regex
    alt Reply/emoji found
        TypingTimeCalculator->>TypingTimeCalculator: Add random delay (1-3 seconds)
    end
    TypingTimeCalculator->>TypingTimeCalculator: Calculate typing time based on characters
    TypingTimeCalculator-->>ChatBot: Typing time
    ChatBot->>ChatBot: Simulate typing
    ChatBot-->>User: Sends response
Loading

File-Level Changes

Change Details Files
Added a random delay to simulate the time taken to find and insert replies, images, or emoticons.
  • Added a regular expression to match reply references and image/emoticon descriptions.
  • If a match is found, the matched text is removed from the input string.
  • A random time between 1 and 3 seconds is added to the total time.
  • Refactored the character counting logic to use is_western_char instead of unicode ranges.
src/plugins/chat/utils.py

Possibly linked issues

  • #0: The PR fixes the issue by excluding image/quote descriptions from the time calculation and adding a small random time.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Dax233 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider extracting the regex pattern into a constant for better readability and maintainability.
  • The re.match check seems redundant since re.sub will handle cases where the pattern isn't found.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@SengokuCola SengokuCola merged commit a30f8b3 into MaiM-with-u:main-fix Apr 3, 2025
2 of 3 checks passed
@Dax233 Dax233 deleted the issue#603 branch April 4, 2025 04:37
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.

2 participants