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;
|
namespace OsRoom = Offsets::Chatroom;
|
||||||
|
|
||||||
#define OS_GET_CHATROOM_MGR 0x1B83BD0
|
using get_chatroom_mgr_t = QWORD (*)();
|
||||||
#define OS_INVITE_MEMBERS 0x2154AE0
|
using add_member_to_chatroom_t = QWORD (*)(QWORD, QWORD, WxString *, QWORD);
|
||||||
|
using del_member_from_chatroom_t = QWORD (*)(QWORD, QWORD, WxString *);
|
||||||
using get_chatroom_mgr_t = QWORD (*)();
|
using invite_members_t = QWORD (*)(const wchar_t *, QWORD, WxString *, 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int add_chatroom_member(const string &roomid, const string &wxids)
|
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)
|
int invite_chatroom_member(const string &roomid, const string &wxids)
|
||||||
{
|
{
|
||||||
if (roomid.empty() || wxids.empty()) {
|
invite_members_t invite_members = reinterpret_cast<invite_members_t>(g_WeChatWinDllAddr + OsRoom::INV);
|
||||||
LOG_ERROR("Empty roomid or wxids.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
invite_member_to_chatroom_t invite_members
|
wstring ws_roomid = util::s2w(roomid);
|
||||||
= reinterpret_cast<invite_member_to_chatroom_t>(g_WeChatWinDllAddr + OS_INVITE_MEMBERS);
|
WxString *wx_roomid = util::CreateWxString(roomid);
|
||||||
|
|
||||||
vector<WxString> wx_members = parse_wxids(wxids);
|
QWORD tmp[2] = { 0 };
|
||||||
auto wx_roomid = util::new_wx_string(roomid);
|
auto wx_members = util::parse_wxids(wxids).wxWxids;
|
||||||
QWORD p_members = reinterpret_cast<QWORD>(&wx_members.front());
|
QWORD p_members = reinterpret_cast<QWORD>(&wx_members);
|
||||||
|
|
||||||
return static_cast<int>(invite_members(reinterpret_cast<QWORD>(wx_roomid.get()->wptr), p_members,
|
return static_cast<int>(invite_members(ws_roomid.c_str(), p_members, wx_roomid, reinterpret_cast<QWORD>(tmp)));
|
||||||
reinterpret_cast<QWORD>(wx_roomid.get()), 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rpc_add_chatroom_member(const MemberMgmt &m, uint8_t *out, size_t *len)
|
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)
|
bool rpc_invite_chatroom_member(const MemberMgmt &m, uint8_t *out, size_t *len)
|
||||||
{
|
{
|
||||||
const std::string wxids = m.wxids;
|
int status = -1;
|
||||||
const std::string roomid = m.roomid;
|
if (m.wxids && m.roomid) {
|
||||||
return fill_response<Functions_FUNC_INV_ROOM_MEMBERS>(
|
const std::string wxids = m.wxids;
|
||||||
out, len, [&](Response &rsp) { rsp.msg.status = invite_chatroom_member(roomid, 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
|
} // 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_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_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_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
|
// clang-format on
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user