feat(chatroom): impl invite chatroom members
This commit is contained in:
parent
84338c85d1
commit
aefea53bdd
@ -14,24 +14,10 @@ namespace chatroom
|
||||
{
|
||||
namespace OsRoom = Offsets::Chatroom;
|
||||
|
||||
#define OS_GET_CHATROOM_MGR 0x1B83BD0
|
||||
#define OS_INVITE_MEMBERS 0x2154AE0
|
||||
|
||||
using get_chatroom_mgr_t = QWORD (*)();
|
||||
using add_member_to_chatroom_t = QWORD (*)(QWORD, QWORD, WxString *, QWORD);
|
||||
using del_member_from_chatroom_t = QWORD (*)(QWORD, QWORD, WxString *);
|
||||
using invite_member_to_chatroom_t = QWORD (*)(QWORD, QWORD, QWORD, QWORD);
|
||||
|
||||
static vector<WxString> parse_wxids(const string &wxids)
|
||||
{
|
||||
vector<WxString> wx_members;
|
||||
wstringstream wss(util::s2w(wxids));
|
||||
wstring wstr;
|
||||
while (getline(wss, wstr, L',')) {
|
||||
wx_members.emplace_back(wstr);
|
||||
}
|
||||
return wx_members;
|
||||
}
|
||||
using get_chatroom_mgr_t = QWORD (*)();
|
||||
using add_member_to_chatroom_t = QWORD (*)(QWORD, QWORD, WxString *, QWORD);
|
||||
using del_member_from_chatroom_t = QWORD (*)(QWORD, QWORD, WxString *);
|
||||
using invite_members_t = QWORD (*)(const wchar_t *, QWORD, WxString *, QWORD);
|
||||
|
||||
int add_chatroom_member(const string &roomid, const string &wxids)
|
||||
{
|
||||
@ -62,20 +48,16 @@ int del_chatroom_member(const string &roomid, const string &wxids)
|
||||
|
||||
int invite_chatroom_member(const string &roomid, const string &wxids)
|
||||
{
|
||||
if (roomid.empty() || wxids.empty()) {
|
||||
LOG_ERROR("Empty roomid or wxids.");
|
||||
return -1;
|
||||
}
|
||||
invite_members_t invite_members = reinterpret_cast<invite_members_t>(g_WeChatWinDllAddr + OsRoom::INV);
|
||||
|
||||
invite_member_to_chatroom_t invite_members
|
||||
= reinterpret_cast<invite_member_to_chatroom_t>(g_WeChatWinDllAddr + OS_INVITE_MEMBERS);
|
||||
wstring ws_roomid = util::s2w(roomid);
|
||||
WxString *wx_roomid = util::CreateWxString(roomid);
|
||||
|
||||
vector<WxString> wx_members = parse_wxids(wxids);
|
||||
auto wx_roomid = util::new_wx_string(roomid);
|
||||
QWORD p_members = reinterpret_cast<QWORD>(&wx_members.front());
|
||||
QWORD tmp[2] = { 0 };
|
||||
auto wx_members = util::parse_wxids(wxids).wxWxids;
|
||||
QWORD p_members = reinterpret_cast<QWORD>(&wx_members);
|
||||
|
||||
return static_cast<int>(invite_members(reinterpret_cast<QWORD>(wx_roomid.get()->wptr), p_members,
|
||||
reinterpret_cast<QWORD>(wx_roomid.get()), 0));
|
||||
return static_cast<int>(invite_members(ws_roomid.c_str(), p_members, wx_roomid, reinterpret_cast<QWORD>(tmp)));
|
||||
}
|
||||
|
||||
bool rpc_add_chatroom_member(const MemberMgmt &m, uint8_t *out, size_t *len)
|
||||
@ -110,10 +92,17 @@ bool rpc_delete_chatroom_member(const MemberMgmt &m, uint8_t *out, size_t *len)
|
||||
|
||||
bool rpc_invite_chatroom_member(const MemberMgmt &m, uint8_t *out, size_t *len)
|
||||
{
|
||||
const std::string wxids = m.wxids;
|
||||
const std::string roomid = m.roomid;
|
||||
return fill_response<Functions_FUNC_INV_ROOM_MEMBERS>(
|
||||
out, len, [&](Response &rsp) { rsp.msg.status = invite_chatroom_member(roomid, wxids); });
|
||||
int status = -1;
|
||||
if (m.wxids && m.roomid) {
|
||||
const std::string wxids = m.wxids;
|
||||
const std::string roomid = m.roomid;
|
||||
|
||||
status = invite_chatroom_member(roomid, wxids);
|
||||
} else {
|
||||
LOG_ERROR("wxid 和 roomid 不能为空");
|
||||
}
|
||||
|
||||
return fill_response<Functions_FUNC_INV_ROOM_MEMBERS>(out, len, [&](Response &rsp) { rsp.msg.status = status; });
|
||||
}
|
||||
|
||||
} // namespace chatroom
|
||||
|
@ -268,7 +268,7 @@ const std::unordered_map<Functions, RpcServer::FunctionHandler> RpcServer::rpcFu
|
||||
{ Functions_FUNC_EXEC_OCR, [](const Request &r, uint8_t *out, size_t *len) { return misc::rpc_get_ocr_result(r.msg.str, out, len); } },
|
||||
{ Functions_FUNC_ADD_ROOM_MEMBERS, [](const Request &r, uint8_t *out, size_t *len) { return chatroom::rpc_add_chatroom_member(r.msg.m, out, len); } },
|
||||
{ Functions_FUNC_DEL_ROOM_MEMBERS, [](const Request &r, uint8_t *out, size_t *len) { return chatroom::rpc_delete_chatroom_member(r.msg.m, out, len); } },
|
||||
// { Functions_FUNC_INV_ROOM_MEMBERS, [](const Request &r, uint8_t *out, size_t *len) { return chatroom::rpc_invite_chatroom_member(r.msg.m, out, len); } },
|
||||
{ Functions_FUNC_INV_ROOM_MEMBERS, [](const Request &r, uint8_t *out, size_t *len) { return chatroom::rpc_invite_chatroom_member(r.msg.m, out, len); } },
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user