mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2024-11-23 12:41:05 +08:00
fix?
This commit is contained in:
parent
2fd551e2ac
commit
f1830d978a
|
@ -86,8 +86,8 @@ class Player:
|
||||||
name_lst[2] = name_lst[0]
|
name_lst[2] = name_lst[0]
|
||||||
else:
|
else:
|
||||||
name_lst[0] = name_lst[2]
|
name_lst[0] = name_lst[2]
|
||||||
name_bytes = name_lst[0].encode()
|
name_bytes = name_lst[0].encode(encoding="utf-8")
|
||||||
team_bytes = name_lst[2].encode()
|
team_bytes = name_lst[2].encode(encoding="utf-8")
|
||||||
self.name = name_lst[0]
|
self.name = name_lst[0]
|
||||||
self.team = name_lst[2]
|
self.team = name_lst[2]
|
||||||
self.name_len = len(name_lst[0])
|
self.name_len = len(name_lst[0])
|
||||||
|
@ -187,17 +187,10 @@ class Player:
|
||||||
cache = io.StringIO()
|
cache = io.StringIO()
|
||||||
cache.write(f"{self.name}@{self.team}|")
|
cache.write(f"{self.name}@{self.team}|")
|
||||||
full = sum(self.name_prop[0:7]) + round(self.name_prop[7] / 3)
|
full = sum(self.name_prop[0:7]) + round(self.name_prop[7] / 3)
|
||||||
datas = [
|
datas = [self.name_prop[7], *self.name_prop[0:7], full]
|
||||||
self.name_prop[7],
|
|
||||||
*self.name_prop[0:7],
|
|
||||||
full
|
|
||||||
]
|
|
||||||
cache.write(
|
cache.write(
|
||||||
"|".join(
|
"|".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")
|
cache.write("\n")
|
||||||
|
@ -205,7 +198,9 @@ class Player:
|
||||||
"|".join(
|
"|".join(
|
||||||
[
|
[
|
||||||
f"{sklname[self.skl_id[index]]}:{self.skl_freq[index]}"
|
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
|
if value > 0
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,7 +14,13 @@ if str(Path(__file__).parent.absolute()) not in sys.path:
|
||||||
import name_utils
|
import name_utils
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ica_typing import IcaNewMessage, IcaClient, ConfigData, ReciveMessage, TailchatReciveMessage
|
from ica_typing import (
|
||||||
|
IcaNewMessage,
|
||||||
|
IcaClient,
|
||||||
|
ConfigData,
|
||||||
|
ReciveMessage,
|
||||||
|
TailchatReciveMessage,
|
||||||
|
)
|
||||||
|
|
||||||
CONFIG_DATA: ConfigData
|
CONFIG_DATA: ConfigData
|
||||||
else:
|
else:
|
||||||
|
@ -30,6 +36,7 @@ _version_ = "0.5.0"
|
||||||
EVAL_PREFIX = "/namerena"
|
EVAL_PREFIX = "/namerena"
|
||||||
CONVERT_PREFIX = "/namer-peek"
|
CONVERT_PREFIX = "/namer-peek"
|
||||||
|
|
||||||
|
|
||||||
def convert_name(msg: ReciveMessage, client) -> None:
|
def convert_name(msg: ReciveMessage, client) -> None:
|
||||||
# 也是多行
|
# 也是多行
|
||||||
if msg.content.find("\n") == -1:
|
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()}")
|
reply = msg.reply_with(f"发生错误:{e}\n{traceback.format_exc()}")
|
||||||
client.send_message(reply)
|
client.send_message(reply)
|
||||||
|
|
||||||
|
|
||||||
def dispatch_msg(msg: ReciveMessage, client) -> None:
|
def dispatch_msg(msg: ReciveMessage, client) -> None:
|
||||||
if msg.is_reply or msg.is_from_self:
|
if msg.is_reply or msg.is_from_self:
|
||||||
return
|
return
|
||||||
|
@ -112,8 +120,8 @@ def dispatch_msg(msg: ReciveMessage, client) -> None:
|
||||||
|
|
||||||
|
|
||||||
def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> 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:
|
def on_tailchat_message(msg: TailchatReciveMessage, client) -> None:
|
||||||
dispatch_msg(msg, client) # type: ignore
|
dispatch_msg(msg, client) # type: ignore
|
||||||
|
|
Loading…
Reference in New Issue
Block a user