From 025020c503ef5b8dc0270197c5b1e6d4e0f8807d Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Tue, 18 Apr 2023 18:03:02 +0800 Subject: ✨本体文件 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/alicebot_plugin_send/__init__.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 plugins/alicebot_plugin_send/__init__.py (limited to 'plugins/alicebot_plugin_send/__init__.py') diff --git a/plugins/alicebot_plugin_send/__init__.py b/plugins/alicebot_plugin_send/__init__.py new file mode 100644 index 0000000..46264ed --- /dev/null +++ b/plugins/alicebot_plugin_send/__init__.py @@ -0,0 +1,28 @@ +import re + +from plugins.alicebot_plugin_base import CommandPluginBase + +from .config import Config + + +class Send(CommandPluginBase[None, Config]): + Config = Config + + def __post_init__(self): + self.re_pattern = re.compile(r"\s*(?P.*)", flags=re.I) + + async def handle(self) -> None: + try: + await self.event.adapter.send( + self.msg_match.group("message"), + "private", + self.config.send_user_id, + ) + except Exception as e: + if self.config.send_filed_msg is not None: + await self.event.reply( + self.format_str(self.config.send_filed_msg, repr(e)) + ) + else: + if self.config.send_success_msg is not None: + await self.event.reply(self.format_str(self.config.send_success_msg)) -- cgit v1.2.3-70-g09d2