更新到 0.7.0 api

This commit is contained in:
shenjack 2024-08-18 02:41:04 +08:00
parent 6e6bcd0830
commit dd8a4983c0
Signed by: shenjack
GPG Key ID: 7B1134A979775551
3 changed files with 41 additions and 27 deletions

View File

@ -170,13 +170,17 @@ class IcaClient:
def version(self) -> str:
...
@property
def startup_time(self) -> datetime:
"""请注意, 此时刻为 UTC 时刻"""
def version_str(self) -> str:
"""获取一个更完善的版本号信息"""
...
@property
def ica_version(self) -> str:
"""shenbot ica 的版本号"""
...
@property
def startup_time(self) -> datetime:
"""请注意, 此时刻为 UTC 时刻"""
...
def debug(self, message: str) -> None:
"""向日志中输出调试信息"""
...
@ -271,6 +275,10 @@ class TailchatClient:
def version(self) -> str:
...
@property
def version_str(self) -> str:
"""获取一个更完善的版本号信息"""
...
@property
def tailchat_version(self) -> str:
"""tailchat 的版本号"""
...

View File

@ -52,7 +52,7 @@ def local_env_info() -> str:
def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> None:
if not (msg.is_from_self or msg.is_reply):
if msg.content == "/bot":
if msg.content == "/bot-py":
reply = msg.reply_with(f"ica-async-rs({client.version})-sync-py {client.ica_version}")
client.send_message(reply)
elif msg.content == "/bot-sys":
@ -69,7 +69,7 @@ def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> None:
def on_tailchat_message(msg: TailchatReciveMessage, client: TailchatClient) -> None:
if not (msg.is_reply or msg.is_from_self):
if msg.content == "/bot":
if msg.content == "/bot-py":
reply = msg.reply_with(f"tailchat-async-rs({client.version})-sync-py {client.tailchat_version}")
client.send_message(reply)
elif msg.content == "/bot-sys":

View File

@ -9,11 +9,12 @@ else:
IcaNewMessage = TypeVar("NewMessage")
IcaClient = TypeVar("IcaClient")
VERSION = "1.2.0"
def gen_room() -> dict[int, dict[int, str]]:
return {i: {} for i in range(0, 24)}
VOTE: dict[int, dict[int, str]] = {}
VOTE: dict[int, dict[int, dict[int, str]]] = {}
def fmt_vote(room_id) -> str:
@ -25,6 +26,27 @@ def fmt_vote(room_id) -> str:
)
HELP_MSG = f"""/hyp - 计划时间,高效开黑-v{VERSION}
SYNOPSIS
/hyp [command] [args]
OPTIONS
vote <space seperated hour>
vote for time you want to play
unvote <space seperated hour>
unvote for time you want to play
clear
clear the vote (OP only)
ls
list voted time, equivalent to empty
view <space seperated hour>
view who vote for the time
help
show this help
AUTHOR
dongdigua
shenjack(bugfixs)
"""
def hypvote(msg: IcaNewMessage, client: IcaClient):
global VOTE
matchs = re.match("/hyp (.+)", msg.content + " ")
@ -44,7 +66,7 @@ def hypvote(msg: IcaNewMessage, client: IcaClient):
for x in arg[1:]:
if x.isdigit() and 0 <= int(x) < 24:
if msg.sender_id in VOTE[msg.room_id][int(x) % 24]:
VOTE[msg.room_id][int(x) % 24][msg.sender_id] = None
del VOTE[msg.room_id][int(x) % 24][msg.sender_id]
elif arg[0] == "clear":
VOTE[msg.room_id] = gen_room()
elif arg[0] == "view":
@ -58,30 +80,14 @@ def hypvote(msg: IcaNewMessage, client: IcaClient):
reply = msg.reply_with(res)
client.send_message(reply)
elif arg[0] == "help":
reply = msg.reply_with("""NAME
/hyp - 计划时间高效开黑
SYNOPSIS
/hyp [command] [args]
OPTIONS
vote <space seperated hour>
vote for time you want to play
unvote <space seperated hour>
unvote for time you want to play
clear
clear the vote (OP only)
ls
list voted time, equivalent to empty
view <space seperated hour>
view who vote for the time
help
show this help
AUTHOR
dongdigua
shenjack(bugfixs)
""")
reply = msg.reply_with(HELP_MSG)
client.send_message(reply)
def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> None:
if (not (msg.is_from_self or msg.is_reply)) and msg.content.startswith("/hyp"):
if msg.content == "/hyp":
reply = msg.reply_with(HELP_MSG)
client.send_message(reply)
return
hypvote(msg, client)