From 1e81db998f46ada9b5c7f44ca59eca100350672b Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 15 Jun 2024 02:46:46 +0800 Subject: [PATCH] p4? --- ica-rs/ica_typing.py | 6 +++--- ica-rs/src/data_struct/tailchat/messages.rs | 4 ++++ ica-rs/src/py/class/tailchat.rs | 2 ++ ica-rs/src/tailchat/events.rs | 4 ++-- news.md | 2 ++ 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ica-rs/ica_typing.py b/ica-rs/ica_typing.py index 315bf67..13493b0 100644 --- a/ica-rs/ica_typing.py +++ b/ica-rs/ica_typing.py @@ -188,9 +188,9 @@ class TailchatReciveMessage: @property def sender_id(self) -> TailchatType.UserId: ... - # @property - # def is_from_self(self) -> bool: - # ... + @property + def is_from_self(self) -> bool: + ... @property def is_reply(self) -> bool: ... diff --git a/ica-rs/src/data_struct/tailchat/messages.rs b/ica-rs/src/data_struct/tailchat/messages.rs index 0ac68f4..6c28e6f 100644 --- a/ica-rs/src/data_struct/tailchat/messages.rs +++ b/ica-rs/src/data_struct/tailchat/messages.rs @@ -47,6 +47,10 @@ impl ReceiveMessage { } } + pub fn is_from_self(&self) -> bool { + crate::MainStatus::global_tailchat_status().user_id == self.sender_id + } + /// 创建一个对这条消息的回复 pub fn as_reply(&self) -> SendingMessage { SendingMessage::new( diff --git a/ica-rs/src/py/class/tailchat.rs b/ica-rs/src/py/class/tailchat.rs index 57a4f1e..9e6d46a 100644 --- a/ica-rs/src/py/class/tailchat.rs +++ b/ica-rs/src/py/class/tailchat.rs @@ -80,6 +80,8 @@ impl TailchatReceiveMessagePy { #[getter] pub fn get_is_reply(&self) -> bool { self.message.is_reply() } #[getter] + pub fn get_is_from_self(&self) -> bool { self.message.is_from_self() } + #[getter] pub fn get_msg_id(&self) -> MessageId { self.message.msg_id.clone() } #[getter] pub fn get_content(&self) -> String { self.message.content.clone() } diff --git a/ica-rs/src/tailchat/events.rs b/ica-rs/src/tailchat/events.rs index f4d132a..52fc9f1 100644 --- a/ica-rs/src/tailchat/events.rs +++ b/ica-rs/src/tailchat/events.rs @@ -104,8 +104,8 @@ pub async fn on_converse_update(payload: Payload, client: Client) { let update_info: UpdateDMConverse = match serde_json::from_value(value.clone()) { Ok(value) => value, Err(e) => { - info!("tailchat updateDMConverse {}", value.to_string().red()); - info!("tailchat updateDMConverse {}", format!("{:?}", e).red()); + event!(Level::WARN, "tailchat updateDMConverse {}", value.to_string().red()); + event!(Level::WARN, "tailchat updateDMConverse {}", format!("{:?}", e).red()); return; } }; diff --git a/news.md b/news.md index 20df687..f909da9 100644 --- a/news.md +++ b/news.md @@ -14,6 +14,8 @@ - 因为现在他俩已经进到 `rust_socketio` 里啦 - 添加了新的 macro - `` +- 支持了 `TailchatReceiveMessagePy` 的 `is_from_self` 方法 + - 用于判断是否是自己发的消息 ## 0.6.7