From 0275863cfeda890690bc238b478a43fe3a98d627 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 10 Jan 2025 22:37:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=90=E5=91=90=E5=91=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ica-rs/src/data_struct/ica/all_rooms.rs | 16 +++++++++------- ica-rs/src/ica/client.rs | 2 +- news.md | 11 +++++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ica-rs/src/data_struct/ica/all_rooms.rs b/ica-rs/src/data_struct/ica/all_rooms.rs index b93d026..dde732b 100644 --- a/ica-rs/src/data_struct/ica/all_rooms.rs +++ b/ica-rs/src/data_struct/ica/all_rooms.rs @@ -2,7 +2,7 @@ use crate::data_struct::ica::messages::{At, LastMessage}; use crate::data_struct::ica::RoomId; use serde::{Deserialize, Serialize}; -use serde_json::{Number, Value as JsonValue}; +use serde_json::Value as JsonValue; /// export default interface Room { /// roomId: number @@ -39,14 +39,16 @@ pub struct Room { impl Room { pub fn new_from_json(raw_json: &JsonValue) -> Self { - let mut parse_json = raw_json.clone(); + let parse_json = raw_json.clone(); // 手动 patch 一下 roomId // ica issue: https://github.com/Icalingua-plus-plus/Icalingua-plus-plus/issues/793 - if parse_json.get("roomId").is_none_or(|id| id.is_null()) { - use tracing::warn; - warn!("Room::new_from_json roomId is None, patching it to -1, raw: {:#?}", raw_json); - parse_json["roomId"] = JsonValue::Number(Number::from(-1)); - } + // if parse_json.get("roomId").is_none_or(|id| id.is_null()) { + // use tracing::warn; + // warn!("Room::new_from_json roomId is None, patching it to -1, raw: {:#?}", raw_json); + // parse_json["roomId"] = JsonValue::Number(Number::from(-1)); + // } + // 现在 fix 了 + let inner = match serde_json::from_value::(parse_json) { Ok(data) => data, Err(e) => { diff --git a/ica-rs/src/ica/client.rs b/ica-rs/src/ica/client.rs index 2ec1345..86df8a2 100644 --- a/ica-rs/src/ica/client.rs +++ b/ica-rs/src/ica/client.rs @@ -129,7 +129,7 @@ pub async fn send_room_sign_in(client: &Client, room_id: RoomId) -> bool { /// 向某个群/私聊的某个人发送戳一戳 pub async fn send_poke(client: &Client, room_id: RoomId, target: UserId) -> bool { - let data = json!([room_id, target]); + let data = vec![json!(room_id), json!(target)]; match client.emit("sendGroupPoke", data).await { Ok(_) => { event!(Level::INFO, "已向 {} 的 {} 发送戳一戳", room_id, target); diff --git a/news.md b/news.md index 325d61d..26af8f9 100644 --- a/news.md +++ b/news.md @@ -1,5 +1,16 @@ # 更新日志 +## 0.8.1 + +- `ica-typing` 加入了 `from __future__ import annotations` + - 这样就可以随便用 typing 了 + - 把 NewType 都扬了 + +### ica 1.6.6 + +- 修复了 `send_poke` api 的问题 + - 现在可以正常使用了 + ## 0.8.0 - ica 兼容版本号更新到 ~~`2.12.24`~~ `2.12.26`