This commit is contained in:
shenjack 2024-06-22 19:36:13 +08:00
parent 2fd551e2ac
commit f1830d978a
Signed by: shenjack
GPG Key ID: 7B1134A979775551
2 changed files with 18 additions and 15 deletions

View File

@ -86,8 +86,8 @@ class Player:
name_lst[2] = name_lst[0]
else:
name_lst[0] = name_lst[2]
name_bytes = name_lst[0].encode()
team_bytes = name_lst[2].encode()
name_bytes = name_lst[0].encode(encoding="utf-8")
team_bytes = name_lst[2].encode(encoding="utf-8")
self.name = name_lst[0]
self.team = name_lst[2]
self.name_len = len(name_lst[0])
@ -187,17 +187,10 @@ class Player:
cache = io.StringIO()
cache.write(f"{self.name}@{self.team}|")
full = sum(self.name_prop[0:7]) + round(self.name_prop[7] / 3)
datas = [
self.name_prop[7],
*self.name_prop[0:7],
full
]
datas = [self.name_prop[7], *self.name_prop[0:7], full]
cache.write(
"|".join(
[
f"{prop_names[index]}:{value}"
for index, value in enumerate(datas)
]
[f"{prop_names[index]}:{value}" for index, value in enumerate(datas)]
)
)
cache.write("\n")
@ -205,7 +198,9 @@ class Player:
"|".join(
[
f"{sklname[self.skl_id[index]]}:{self.skl_freq[index]}"
for index, value in enumerate(self.skl_freq)
for index, value in sorted(
enumerate(self.skl_freq), key=lambda x: x[1], reverse=True
)
if value > 0
]
)

View File

@ -14,7 +14,13 @@ if str(Path(__file__).parent.absolute()) not in sys.path:
import name_utils
if TYPE_CHECKING:
from ica_typing import IcaNewMessage, IcaClient, ConfigData, ReciveMessage, TailchatReciveMessage
from ica_typing import (
IcaNewMessage,
IcaClient,
ConfigData,
ReciveMessage,
TailchatReciveMessage,
)
CONFIG_DATA: ConfigData
else:
@ -30,6 +36,7 @@ _version_ = "0.5.0"
EVAL_PREFIX = "/namerena"
CONVERT_PREFIX = "/namer-peek"
def convert_name(msg: ReciveMessage, client) -> None:
# 也是多行
if msg.content.find("\n") == -1:
@ -102,6 +109,7 @@ def eval_fight(msg: ReciveMessage, client) -> None:
reply = msg.reply_with(f"发生错误:{e}\n{traceback.format_exc()}")
client.send_message(reply)
def dispatch_msg(msg: ReciveMessage, client) -> None:
if msg.is_reply or msg.is_from_self:
return
@ -112,8 +120,8 @@ def dispatch_msg(msg: ReciveMessage, client) -> None:
def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> None:
dispatch_msg(msg, client) # type: ignore
dispatch_msg(msg, client) # type: ignore
def on_tailchat_message(msg: TailchatReciveMessage, client) -> None:
dispatch_msg(msg, client) # type: ignore
dispatch_msg(msg, client) # type: ignore