From 5544cb02ad84d4da6bd967e09854e9cad29fe33d Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Mon, 2 Sep 2024 01:12:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/bmcl.py | 1 - plugins/re_send.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 plugins/re_send.py diff --git a/plugins/bmcl.py b/plugins/bmcl.py index b3d3216..c544423 100644 --- a/plugins/bmcl.py +++ b/plugins/bmcl.py @@ -3,7 +3,6 @@ import io import time import requests import traceback -import urllib.parse # import PIL diff --git a/plugins/re_send.py b/plugins/re_send.py new file mode 100644 index 0000000..4248cbe --- /dev/null +++ b/plugins/re_send.py @@ -0,0 +1,31 @@ +from __future__ import annotations +from typing import TYPE_CHECKING, TypeVar + +if TYPE_CHECKING: + from ica_typing import IcaNewMessage, IcaClient + from ica_typing import TailchatReciveMessage, TailchatClient +else: + IcaNewMessage = TypeVar("NewMessage") + IcaClient = TypeVar("IcaClient") + TailchatReciveMessage = TypeVar("TailchatReciveMessage") + TailchatClient = TypeVar("TailchatClient") + + +TC_client: TailchatClient | None = None +TC_msg: TailchatReciveMessage | None = None + + +def on_tailchat_message(msg: TailchatReciveMessage, client: TailchatClient) -> None: + global TC_client, TC_msg + TC_client = client + if msg.is_reply or msg.is_from_self: + return + if msg.content == "/send-here": + TC_msg = msg + + +def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> None: + if TC_client is None or TC_msg is None: + return + reply = TC_msg.reply_with(f"From ICA:|{msg.room_id}|{msg.sender_id}|{msg.sender_name}|{msg.content}") + TC_client.send_message(reply)