Skip to content
New issue

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

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

Already on GitHub? # to your account

🐛 修复功能少时zhenxun帮助图片排序问题 #1620

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions zhenxun/builtin_plugins/help/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async def build_ss_image(self, bot_id: str, group_id: str | None) -> bytes:
)
max_len = 0
flag_index = -1
max_data = None
max_data = {}
plugin_list = []
for index, plu in enumerate(classify.keys()):
data = {
Expand All @@ -124,9 +124,24 @@ async def build_ss_image(self, bot_id: str, group_id: str | None) -> bytes:
max_data = data
plugin_list.append(data)
del plugin_list[flag_index]
plugin_list.insert(0, max_data)
# plugin_list.insert(0, max_data)
Copy link
Contributor

Choose a reason for hiding this comment

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

建议: 如果不再需要,请删除注释掉的代码

如果这行代码不再需要,最好完全删除它,而不是将其注释掉。这有助于保持代码的整洁和可读性。

Suggested change
# plugin_list.insert(0, max_data)
plugin_list.insert(0, max_data)
Original comment in English

suggestion: Remove commented-out code if no longer needed

If this line is no longer needed, it's better to remove it entirely rather than leaving it commented out. This helps maintain cleaner, more readable code.

Suggested change
# plugin_list.insert(0, max_data)
plugin_list.insert(0, max_data)

_data = []
_left = 30
_pu1 = []
_pu2 = []
for i in range(len(max_data["items"])):
if i % 2:
_pu1.append(max_data["items"][i])
else:
_pu2.append(max_data["items"][i])
_plugins = [(30, 50, _pu1), (0, 50, _pu2)]
Copy link
Contributor

Choose a reason for hiding this comment

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

建议: 用命名常量替换魔法数字

这个代码块中的硬编码值(30, 50, 0, 100)可以通过命名常量替换来受益。这将提高可读性和可维护性。考虑在文件顶部或配置文件中定义这些常量。

FIRST_COLUMN_WIDTH = 30
SECOND_COLUMN_WIDTH = 50
THIRD_COLUMN_WIDTH = 0

_plugins = [(FIRST_COLUMN_WIDTH, SECOND_COLUMN_WIDTH, _pu1),
            (THIRD_COLUMN_WIDTH, SECOND_COLUMN_WIDTH, _pu2)]
Original comment in English

suggestion: Replace magic numbers with named constants

The hardcoded values (30, 50, 0, 100) in this block could benefit from being replaced with named constants. This would improve readability and maintainability. Consider defining these at the top of the file or in a configuration file.

FIRST_COLUMN_WIDTH = 30
SECOND_COLUMN_WIDTH = 50
THIRD_COLUMN_WIDTH = 0

_plugins = [(FIRST_COLUMN_WIDTH, SECOND_COLUMN_WIDTH, _pu1),
            (THIRD_COLUMN_WIDTH, SECOND_COLUMN_WIDTH, _pu2)]

_data.append(
{
"name": max_data["name"],
"items": [(30, 50, _pu1), (0, 50, _pu2)],
"width": 100,
}
)
for plugin in plugin_list:
_plugins = []
width = 50
Expand Down
Loading