HibiKier / zhenxun_bot

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

🎨代码优化 #1586

Closed xuanerwa closed 2 months ago

xuanerwa commented 2 months ago

Summary by Sourcery

Optimize the chat checking logic by reordering the module check and enhance the Russian roulette plugin by changing the command argument order to prioritize bullet count over money.

Enhancements:

sourcery-ai[bot] commented 2 months ago

Reviewer's Guide by Sourcery

This pull request optimizes the code for the Russian Roulette game plugin and the chat check scheduler. The main changes include reordering function parameters, improving code efficiency, and enhancing error handling.

File-Level Changes

Change Details Files
Optimized the chat check scheduler logic
  • Moved the TaskInfo query outside the main loop for better performance
  • Restructured the nested loops to reduce indentation
  • Improved error handling by moving the try-except block inside the group loop
zhenxun/builtin_plugins/scheduler/chat_check.py
Modified the Russian Roulette game plugin parameter order and handling
  • Changed the order of parameters in the command from '[金额] [子弹数]' to '[子弹数] ?[金额]'
  • Updated the usage instructions to reflect the new parameter order
  • Modified the function signature and parameter handling to accommodate the new order
  • Made the 'money' parameter optional with a default value of 200
zhenxun/plugins/russian/__init__.py
zhenxun/plugins/russian/command.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.