添加踢出群成员函数

This commit is contained in:
super_wang 2023-07-10 23:07:11 +08:00
parent 3cd4d97a2c
commit 3c835ab121

View File

@ -702,6 +702,35 @@ pub fn add_chatroom_members(
};
}
pub fn del_chatroom_members(
roomid: String,
wxids: String,
wechat: &mut WeChat,
) -> Result<bool, Box<dyn std::error::Error>> {
let req = wcf::Request {
func: wcf::Functions::FuncDelRoomMembers.into(),
msg: Some(wcf::request::Msg::M(wcf::AddMembers { roomid, wxids })),
};
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);
}
};
}
pub fn decrypt_image(
src: String,
dst: String,
@ -864,6 +893,18 @@ mod test {
println!("Status: {}", status);
}
#[test]
fn test_del_chatroom_members() {
let mut wechat = crate::wechat::WeChat::default();
let status = crate::wechat::del_chatroom_members(
String::from("34476879773@chatroom"),
String::from("*******"),
&mut wechat,
)
.unwrap();
println!("Status: {}", status);
}
#[test]
fn test_get_user_info() {
let mut wechat = crate::wechat::WeChat::default();