From 7275e1facf44da482eeb872bbffc26163f3dc3a7 Mon Sep 17 00:00:00 2001 From: super_wang Date: Mon, 17 Jul 2023 23:32:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8B=E5=8F=8B=E5=9C=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clients/rust/wcferry/proto/wcf.proto | 23 ++++++++------ clients/rust/wcferry/src/proto/wcf.rs | 46 +++++++++++++++++---------- clients/rust/wcferry/src/wechat.rs | 36 ++++++++++++++++++--- 3 files changed, 76 insertions(+), 29 deletions(-) diff --git a/clients/rust/wcferry/proto/wcf.proto b/clients/rust/wcferry/proto/wcf.proto index f994171..5cdc36b 100644 --- a/clients/rust/wcferry/proto/wcf.proto +++ b/clients/rust/wcferry/proto/wcf.proto @@ -22,6 +22,7 @@ enum Functions { FUNC_EXEC_DB_QUERY = 0x50; FUNC_ACCEPT_FRIEND = 0x51; FUNC_RECV_TRANSFER = 0x52; + FUNC_REFRESH_PYQ = 0x53; FUNC_DECRYPT_IMAGE = 0x60; FUNC_ADD_ROOM_MEMBERS = 0x70; FUNC_DEL_ROOM_MEMBERS = 0x71; @@ -42,6 +43,8 @@ message Request XmlMsg xml = 9; DecPath dec = 10; Transfer tf = 11; + uint64 ui64 = 12; // 64 位整数,通用 + bool flag = 13; } } @@ -68,14 +71,16 @@ message WxMsg { bool is_self = 1; // 是否自己发送的 bool is_group = 2; // 是否群消息 - int32 type = 3; // 消息类型 - string id = 4; // 消息 id - string xml = 5; // 消息 xml - string sender = 6; // 消息发送者 - string roomid = 7; // 群 id(如果是群消息的话) - string content = 8; // 消息内容 - string thumb = 9; // 缩略图 - string extra = 10; // 附加内容 + uint64 id = 3; // 消息 id + uint32 type = 4; // 消息类型 + uint32 ts = 5; // 消息类型 + string roomid = 6; // 群 id(如果是群消息的话) + string content = 7; // 消息内容 + string sender = 8; // 消息发送者 + string sign = 9; // Sign + string thumb = 10; // 缩略图 + string extra = 11; // 附加内容 + string xml = 12; // 消息 xml } message TextMsg @@ -170,4 +175,4 @@ message Transfer string wxid = 1; // 转账人 string tfid = 2; // 转账id transferid string taid = 3; // Transaction id -} \ No newline at end of file +} diff --git a/clients/rust/wcferry/src/proto/wcf.rs b/clients/rust/wcferry/src/proto/wcf.rs index 8123866..13b282d 100644 --- a/clients/rust/wcferry/src/proto/wcf.rs +++ b/clients/rust/wcferry/src/proto/wcf.rs @@ -3,7 +3,7 @@ pub struct Request { #[prost(enumeration = "Functions", tag = "1")] pub func: i32, - #[prost(oneof = "request::Msg", tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11")] + #[prost(oneof = "request::Msg", tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13")] pub msg: ::core::option::Option, } /// Nested message and enum types in `Request`. @@ -31,6 +31,11 @@ pub mod request { Dec(super::DecPath), #[prost(message, tag = "11")] Tf(super::Transfer), + /// 64 位整数,通用 + #[prost(uint64, tag = "12")] + Ui64(u64), + #[prost(bool, tag = "13")] + Flag(bool), } } #[allow(clippy::derive_partial_eq_without_eq)] @@ -87,30 +92,36 @@ pub struct WxMsg { /// 是否群消息 #[prost(bool, tag = "2")] pub is_group: bool, - /// 消息类型 - #[prost(int32, tag = "3")] - pub r#type: i32, /// 消息 id - #[prost(string, tag = "4")] - pub id: ::prost::alloc::string::String, - /// 消息 xml - #[prost(string, tag = "5")] - pub xml: ::prost::alloc::string::String, - /// 消息发送者 - #[prost(string, tag = "6")] - pub sender: ::prost::alloc::string::String, + #[prost(uint64, tag = "3")] + pub id: u64, + /// 消息类型 + #[prost(uint32, tag = "4")] + pub r#type: u32, + /// 消息类型 + #[prost(uint32, tag = "5")] + pub ts: u32, /// 群 id(如果是群消息的话) - #[prost(string, tag = "7")] + #[prost(string, tag = "6")] pub roomid: ::prost::alloc::string::String, /// 消息内容 - #[prost(string, tag = "8")] + #[prost(string, tag = "7")] pub content: ::prost::alloc::string::String, - /// 缩略图 + /// 消息发送者 + #[prost(string, tag = "8")] + pub sender: ::prost::alloc::string::String, + /// Sign #[prost(string, tag = "9")] + pub sign: ::prost::alloc::string::String, + /// 缩略图 + #[prost(string, tag = "10")] pub thumb: ::prost::alloc::string::String, /// 附加内容 - #[prost(string, tag = "10")] + #[prost(string, tag = "11")] pub extra: ::prost::alloc::string::String, + /// 消息 xml + #[prost(string, tag = "12")] + pub xml: ::prost::alloc::string::String, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -331,6 +342,7 @@ pub enum Functions { FuncExecDbQuery = 80, FuncAcceptFriend = 81, FuncRecvTransfer = 82, + FuncRefreshPyq = 83, FuncDecryptImage = 96, FuncAddRoomMembers = 112, FuncDelRoomMembers = 113, @@ -360,6 +372,7 @@ impl Functions { Functions::FuncExecDbQuery => "FUNC_EXEC_DB_QUERY", Functions::FuncAcceptFriend => "FUNC_ACCEPT_FRIEND", Functions::FuncRecvTransfer => "FUNC_RECV_TRANSFER", + Functions::FuncRefreshPyq => "FUNC_REFRESH_PYQ", Functions::FuncDecryptImage => "FUNC_DECRYPT_IMAGE", Functions::FuncAddRoomMembers => "FUNC_ADD_ROOM_MEMBERS", Functions::FuncDelRoomMembers => "FUNC_DEL_ROOM_MEMBERS", @@ -386,6 +399,7 @@ impl Functions { "FUNC_EXEC_DB_QUERY" => Some(Self::FuncExecDbQuery), "FUNC_ACCEPT_FRIEND" => Some(Self::FuncAcceptFriend), "FUNC_RECV_TRANSFER" => Some(Self::FuncRecvTransfer), + "FUNC_REFRESH_PYQ" => Some(Self::FuncRefreshPyq), "FUNC_DECRYPT_IMAGE" => Some(Self::FuncDecryptImage), "FUNC_ADD_ROOM_MEMBERS" => Some(Self::FuncAddRoomMembers), "FUNC_DEL_ROOM_MEMBERS" => Some(Self::FuncDelRoomMembers), diff --git a/clients/rust/wcferry/src/wechat.rs b/clients/rust/wcferry/src/wechat.rs index ad2ce89..91eb843 100644 --- a/clients/rust/wcferry/src/wechat.rs +++ b/clients/rust/wcferry/src/wechat.rs @@ -544,7 +544,7 @@ pub fn enable_listen(wechat: &mut WeChat) -> Result res, @@ -770,8 +770,8 @@ pub fn recv_transfer( func: wcf::Functions::FuncRecvTransfer.into(), msg: Some(wcf::request::Msg::Tf(wcf::Transfer { wxid: wxid, - taid: transferid, - tfid: transcationid, + tfid: transferid, + taid: transcationid, })), }; let response = match send_cmd(wechat, req) { @@ -794,6 +794,32 @@ pub fn recv_transfer( }; } +/** 刷新朋友圈 */ +pub fn refresh_pyq(id: u64, wechat: &mut WeChat) -> Result> { + let req = wcf::Request { + func: wcf::Functions::FuncRefreshPyq.into(), + msg: Some(wcf::request::Msg::Ui64(id)), + }; + let response = match send_cmd(wechat, req) { + Ok(res) => res, + Err(e) => { + error!("命令发送失败: {}", e); + return Err("接收转账失败".into()); + } + }; + if response.is_none() { + return Ok(false); + } + match response.unwrap() { + wcf::response::Msg::Status(status) => { + return Ok(status != -1); + } + _ => { + return Ok(false); + } + }; +} + mod test { #[test] @@ -858,9 +884,11 @@ mod test { fn test_recv_msg() { let mut wechat = crate::wechat::WeChat::default(); let mut socket = crate::wechat::enable_listen(&mut wechat).unwrap(); - for _ in 1..5 { + for _index in 0..5 { + let _ = crate::wechat::refresh_pyq(0, &mut wechat); let msg = crate::wechat::recv_msg(&mut socket).unwrap(); println!("WxMsg: {:?}", msg); + println!("--------------------------------------------------"); } let _ = crate::wechat::disable_listen(&mut wechat); }