From dd8a4983c0f303ed5b05a19272b3f764fc1bee20 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sun, 18 Aug 2024 02:41:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=B0=200.7.0=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ica_typing.py | 12 +++++++++-- plugins/base.py | 4 ++-- plugins/hyp_vote.py | 52 +++++++++++++++++++++++++-------------------- 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/ica_typing.py b/ica_typing.py index 4bd055a..242c357 100644 --- a/ica_typing.py +++ b/ica_typing.py @@ -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 的版本号""" ... diff --git a/plugins/base.py b/plugins/base.py index f464c8d..e7842cd 100644 --- a/plugins/base.py +++ b/plugins/base.py @@ -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": diff --git a/plugins/hyp_vote.py b/plugins/hyp_vote.py index a4263fe..a5178b0 100644 --- a/plugins/hyp_vote.py +++ b/plugins/hyp_vote.py @@ -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 + vote for time you want to play + unvote + unvote for time you want to play + clear + clear the vote (OP only) + ls + list voted time, equivalent to empty + view + 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 - vote for time you want to play - unvote - unvote for time you want to play - clear - clear the vote (OP only) - ls - list voted time, equivalent to empty - view - 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)