HibiKier / zhenxun_bot

基于 Nonebot2 开发,非常可爱的绪山真寻bot
GNU Affero General Public License v3.0
3.36k stars 605 forks source link

修复签到逻辑bug,并使代码更灵活以适应签到好感度等级配置 #1606

Closed McElaga closed 2 months ago

McElaga commented 2 months ago
  1. 重写get_level_and_next_impression函数,更好地整合了好感度等级最低和最高时的逻辑,并且在好感度等级最高时返回的next_impressionimpression相等,与后续判断升级进度相契合(好感度等级最高时进度始终为100%);
  2. 修复部分bug、变量名,提高函数可读性;
  3. 实现在config.py文件更改好感度等级相关配置时,签到功能仍然可用。

Summary by Sourcery

重构登录逻辑以修复与印象等级相关的错误,并提高代码的灵活性和可读性。确保系统适应印象等级的配置更改,并纠正最大印象等级的处理,以保持一致的进度报告。

错误修复:

增强功能:

Original summary in English ## Summary by Sourcery Refactor the sign-in logic to fix bugs related to impression levels and improve code flexibility and readability. Ensure the system adapts to configuration changes in impression levels, and correct the handling of maximum impression levels to maintain consistent progress reporting. Bug Fixes: - Fix the logic in the `get_level_and_next_impression` function to correctly handle the highest impression level, ensuring the progress is always 100% when the maximum level is reached. Enhancements: - Improve the flexibility of the sign-in feature to adapt to changes in impression level configurations in the `config.py` file. - Enhance code readability by renaming variables and refining function logic.
sourcery-ai[bot] commented 2 months ago

审核指南由 Sourcery 提供

此拉取请求重构了登录逻辑,修复了错误,并提高了代码的灵活性,以适应登录印象级别配置。更改主要集中在重写 get_level_and_next_impression 函数、修复变量名,并确保当在 config.py 文件中修改印象级别配置时,登录功能仍然正常。

文件级更改

更改 详情 文件
重写 get_level_and_next_impression 函数以更好地处理逻辑
  • 改进了最小和最大印象级别的处理
  • 确保 next_impression 在最大级别时等于印象
  • 简化了确定当前级别和下一个印象的逻辑
  • 移除了硬编码的级别检查
zhenxun/builtin_plugins/sign_in/utils.py
修复错误并提高代码可读性
  • 更新了变量名以保持一致性
  • 修复了 _generate_html_card 函数中的印象计算
  • 修正了进度条比例计算
  • 添加了断言以确保印象级别配置的一致性
zhenxun/builtin_plugins/sign_in/utils.py
增强印象级别配置的灵活性
  • 从 lik2level 字典中移除了硬编码的级别 9
  • 更新了心形图标生成以使用动态级别计数
  • 修改了级别和印象计算以适应可配置级别
zhenxun/builtin_plugins/sign_in/utils.py
zhenxun/builtin_plugins/sign_in/config.py

提示 - 通过在拉取请求中评论 `@sourcery-ai review` 来触发新的 Sourcery 审核。 - 通过直接回复审核评论继续与 Sourcery 的讨论。 - 您可以随时通过访问您的[仪表板](https://app.sourcery.ai)更改审核设置: - 启用或禁用 Sourcery 生成的拉取请求摘要或审核指南; - 更改审核语言; - 如果您有任何问题或反馈,您可以随时[联系我们](mailto:support@sourcery.ai)。
Original review guide in English ## Reviewer's Guide by Sourcery This pull request refactors the sign-in logic, fixes bugs, and improves code flexibility to accommodate sign-in impression level configurations. The changes primarily focus on rewriting the `get_level_and_next_impression` function, fixing variable names, and ensuring the sign-in feature remains functional when impression level configurations are modified in the `config.py` file. ### File-Level Changes | Change | Details | Files | | ------ | ------- | ----- | | Rewrite get_level_and_next_impression function for better logic handling |
  • Improved handling of minimum and maximum impression levels
  • Ensured next_impression equals impression at maximum level
  • Simplified logic for determining current level and next impression
  • Removed hardcoded level checks
| `zhenxun/builtin_plugins/sign_in/utils.py` | | Fix bugs and improve code readability |
  • Updated variable names for consistency
  • Fixed impression calculation in _generate_html_card function
  • Corrected progress bar ratio calculation
  • Added assertion to ensure consistency in impression level configurations
| `zhenxun/builtin_plugins/sign_in/utils.py` | | Enhance flexibility for impression level configurations |
  • Removed hardcoded level 9 from lik2level dictionary
  • Updated heart icon generation to use dynamic level count
  • Modified level and impression calculations to work with configurable levels
| `zhenxun/builtin_plugins/sign_in/utils.py`
`zhenxun/builtin_plugins/sign_in/config.py` | ---
Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.