From 9ce466f0008000bb948a90b5b19c579f0ee906e1 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Wed, 21 Feb 2024 23:07:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ica-rs/ica_typing.py | 9 +++++---- ica-rs/src/events.rs | 2 +- ica-rs/src/main.rs | 1 - ica-rs/src/py/class.rs | 7 +++++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ica-rs/ica_typing.py b/ica-rs/ica_typing.py index edf3400..078209a 100644 --- a/ica-rs/ica_typing.py +++ b/ica-rs/ica_typing.py @@ -33,13 +33,14 @@ class IcaStatus: ... -class NewMessage: - ... - - class ReplyMessage: ... class SendMessage: ... + + +class NewMessage: + def reply_with(self, message: str) -> SendMessage: + ... diff --git a/ica-rs/src/events.rs b/ica-rs/src/events.rs index c98eea5..065064d 100644 --- a/ica-rs/src/events.rs +++ b/ica-rs/src/events.rs @@ -40,7 +40,7 @@ pub async fn add_message(payload: Payload, client: Client) { // 就在这里处理掉最基本的消息 // 之后的处理交给插件 if message.content.eq("/bot-rs") { - let reply = message.reply_with(&format!("ica-rs pong v{}", VERSION)); + let reply = message.reply_with(&format!("ica-async-rs pong v{}", VERSION)); send_message(client, reply).await; } } diff --git a/ica-rs/src/main.rs b/ica-rs/src/main.rs index 1cbe7e1..2ee9c15 100644 --- a/ica-rs/src/main.rs +++ b/ica-rs/src/main.rs @@ -90,5 +90,4 @@ async fn main() { socket.disconnect().await.expect("Disconnect failed"); info!("Disconnected"); - } diff --git a/ica-rs/src/py/class.rs b/ica-rs/src/py/class.rs index b68f335..559acbf 100644 --- a/ica-rs/src/py/class.rs +++ b/ica-rs/src/py/class.rs @@ -112,6 +112,13 @@ pub struct NewMessagePy { pub msg: NewMessage, } +#[pymethods] +impl NewMessagePy { + pub fn reply_with(&self, content: String) -> SendMessagePy { + SendMessagePy::new(self.msg.reply_with(&content)) + } +} + impl NewMessagePy { pub fn new(msg: &NewMessage) -> Self { Self { msg: msg.clone() }