改进一下bmcl

This commit is contained in:
shenjack 2024-02-22 21:04:20 +08:00
parent f254879cf0
commit 954a5a1b19
Signed by: shenjack
GPG Key ID: 7B1134A979775551

View File

@ -10,7 +10,7 @@ else:
NewMessage = TypeVar("NewMessage") NewMessage = TypeVar("NewMessage")
IcaClient = TypeVar("IcaClient") IcaClient = TypeVar("IcaClient")
_version_ = "2.1.1-rs" _version_ = "2.1.2-rs"
def format_data_size(data_bytes: float) -> str: def format_data_size(data_bytes: float) -> str:
data_lens = ["B", "KB", "MB", "GB", "TB"] data_lens = ["B", "KB", "MB", "GB", "TB"]
@ -147,17 +147,19 @@ def bmcl_rank(msg: NewMessage, client: IcaClient, name: Optional[str]) -> None:
reply = msg.reply_with(f"搜索|{name}|到{len(counts)}个节点, 请用更精确的名字") reply = msg.reply_with(f"搜索|{name}|到{len(counts)}个节点, 请用更精确的名字")
client.send_message(reply) client.send_message(reply)
return return
rank_msgs = []
for i, find in enumerate(finds): for i, find in enumerate(finds):
if find: if find:
rank = ranks[i] rank = ranks[i]
rank_msg = ( rank_msg = (
f"名称: {rank['name']}\n" f"名称: {rank['name']}-No.{i}\n"
# f"-{rank['full']} \n" # f"-{rank['full']} \n"
# f"版本: {rank['version']}\n" # f"版本: {rank['version']}\n"
f"拥有者: {rank['owner']} 状态: {rank['start']}|" f"拥有者: {rank['owner']} 状态: {rank['start']}|"
f"h/d {format_hit_count(rank['rank']['hits'])}|{format_data_size(rank['rank']['bytes'])}" f"h/d {format_hit_count(rank['rank']['hits'])}|{format_data_size(rank['rank']['bytes'])}"
) )
report_msg = f"OpenBMCLAPI 面板v{_version_}-排名\n{rank_msg}\n" rank_msgs.append(rank_msg)
report_msg = f"OpenBMCLAPI 面板v{_version_}-排名\n{'\n'.join(rank_msgs)}\n"
reply = msg.reply_with(report_msg) reply = msg.reply_with(report_msg)
client.info(report_msg) client.info(report_msg)
client.send_message(reply) client.send_message(reply)