feat:群功能

This commit is contained in:
ttttupup 2024-05-07 20:40:29 +08:00
parent c4a9efa322
commit a39dad9e31
4 changed files with 215 additions and 66 deletions

View File

@ -1,54 +1,111 @@
#include "chat_room_controller.h"
#include "json_utils.h"
#include "nlohmann/json.hpp"
#include "spdlog/spdlog.h"
#include "wechat_interface.h"
#include "wechat_service.h"
namespace wxhelper {
std::string ChatController::GetChatRoomDetailInfo(std::string params) {
std::string ChatRoomController::GetChatRoomDetailInfo(std::string params) {
nlohmann::json jp = nlohmann::json::parse(params);
SPDLOG_INFO("GetChatRoomDetailInfo chatRoomId={}", jp["chatRoomId"]);
std::wstring room_id = jsonutils::GetWStringParam(jp, "chatRoomId");
wechat::ChatRoomInfoInner chat_room_detail;
int64_t success = wechat::WeChatService::GetInstance().GetChatRoomDetailInfo(
room_id, chat_room_detail);
nlohmann::json ret_data = {
{"code", success}, {"msg", "success"}, {"data", {}}};
nlohmann::json detail = {
{"chatRoomId", chat_room_detail.chat_room_id},
{"notice", chat_room_detail.notice},
{"admin", chat_room_detail.admin},
{"xml", chat_room_detail.xml},
};
ret_data["data"] = detail;
return ret_data.dump();
}
std::string ChatRoomController::GetMemberFromChatRoom(std::string params) {
nlohmann::json jp = nlohmann::json::parse(params);
SPDLOG_INFO("GetMemberFromChatRoom chatRoomId={}", jp["chatRoomId"]);
std::wstring room_id = jsonutils::GetWStringParam(jp, "chatRoomId");
wechat::ChatRoomMemberInner member;
int64_t success = wechat::WeChatService::GetInstance().GetMemberFromChatRoom(
room_id, member);
nlohmann::json ret_data = {{"code", success}, {"data", {}}, {"msg", "success"}};
if (success > 0) {
nlohmann::json member_info = {
{"admin", member.admin},
{"chatRoomId", member.chat_room_id},
{"members", member.member},
{"adminNickname", member.admin_nickname},
{"memberNickname", member.member_nickname},
};
ret_data["data"] = member_info;
}
return ret_data.dump();
}
std::string ChatRoomController::AddMemberToChatRoom(std::string params) {
nlohmann::json jp = nlohmann::json::parse(params);
SPDLOG_INFO("AddMemberToChatRoom chatRoomId={},memberIds={}",
jp["chatRoomId"], jp["memberIds"]);
std::wstring room_id = jsonutils::GetWStringParam(jp, "chatRoomId");
std::vector<std::wstring> wxids = jsonutils::GetArrayParam(jp, "memberIds");
std::vector<std::wstring> wxid_list;
for (unsigned int i = 0; i < wxids.size(); i++) {
wxid_list.push_back(wxids[i]);
}
int64_t success = wechat::WeChatService::GetInstance().AddMemberToChatRoom(
room_id, wxid_list);
nlohmann::json ret = {
{"code", success}, {"data", {}}, {"msg", "success"}};
return ret.dump();
}
std::string ChatRoomController::DelMemberFromChatRoom(std::string params) {
nlohmann::json jp = nlohmann::json::parse(params);
SPDLOG_INFO("DelMemberFromChatRoom chatRoomId={},memberIds={}",
jp["chatRoomId"], jp["memberIds"]);
std::wstring room_id = jsonutils::GetWStringParam(jp, "chatRoomId");
std::vector<std::wstring> wxids = jsonutils::GetArrayParam(jp, "memberIds");
std::vector<std::wstring> wxid_list;
for (unsigned int i = 0; i < wxids.size(); i++) {
wxid_list.push_back(wxids[i]);
}
INT64 success = wechat::WeChatService::GetInstance().DelMemberFromChatRoom(
room_id, wxid_list);
nlohmann::json ret_data = {
{"code", success}, {"msg", "success"}, {"data", {}}};
return ret_data.dump();
}
std::string ChatRoomController::CreateChatRoom(std::string params) {
nlohmann::json ret = {
{"code", 200}, {"data", {}}, {"msg", "Not Implemented"}};
return ret.dump();
}
std::string ChatController::GetMemberFromChatRoom(std::string params) {
std::string ChatRoomController::QuitChatRoom(std::string params) {
nlohmann::json ret = {
{"code", 200}, {"data", {}}, {"msg", "Not Implemented"}};
return ret.dump();
}
std::string ChatController::AddMemberToChatRoom(std::string params) {
std::string ChatRoomController::InviteMemberToChatRoom(std::string params) {
nlohmann::json ret = {
{"code", 200}, {"data", {}}, {"msg", "Not Implemented"}};
return ret.dump();
}
std::string ChatController::DelMemberFromChatRoom(std::string params) {
std::string ChatRoomController::TopMsg(std::string params) {
return std::string();
}
std::string ChatRoomController::RemoveTopMsg(std::string params) {
nlohmann::json ret = {
{"code", 200}, {"data", {}}, {"msg", "Not Implemented"}};
return ret.dump();
}
std::string ChatController::CreateChatRoom(std::string params) {
std::string ChatRoomController::GetChatRoomMemberNickname(std::string params) {
nlohmann::json ret = {
{"code", 200}, {"data", {}}, {"msg", "Not Implemented"}};
return ret.dump();
}
std::string ChatController::QuitChatRoom(std::string params) {
nlohmann::json ret = {
{"code", 200}, {"data", {}}, {"msg", "Not Implemented"}};
return ret.dump();
}
std::string ChatController::InviteMemberToChatRoom(std::string params) {
nlohmann::json ret = {
{"code", 200}, {"data", {}}, {"msg", "Not Implemented"}};
return ret.dump();
}
std::string ChatController::TopMsg(std::string params) { return std::string(); }
std::string ChatController::RemoveTopMsg(std::string params) {
nlohmann::json ret = {
{"code", 200}, {"data", {}}, {"msg", "Not Implemented"}};
return ret.dump();
}
std::string ChatController::GetChatRoomMemberNickname(std::string params) {
nlohmann::json ret = {
{"code", 200}, {"data", {}}, {"msg", "Not Implemented"}};
return ret.dump();
}
std::string ChatController::ModifyChatRoomMemberNickName(std::string params) {
std::string ChatRoomController::ModifyChatRoomMemberNickName(
std::string params) {
nlohmann::json ret = {
{"code", 200}, {"data", {}}, {"msg", "Not Implemented"}};
return ret.dump();

View File

@ -4,7 +4,7 @@
#include "http_controller.h"
namespace wxhelper {
class ChatController : public http::HttpController<ChatController> {
class ChatRoomController : public http::HttpController<ChatRoomController> {
public:
PATHS_BEGIN
ADD_PATH("/api/getChatRoomDetailInfo", GetChatRoomDetailInfo);

View File

@ -260,43 +260,33 @@ const uint64_t kGetAppMsgMgr = 0x1c23610;
const uint64_t kGetContactMgr = 0x1c0bdc0;
const uint64_t kGetContactList = 0x22665a0;
const uint64_t k_sqlite3_exec = 0x288ea10;
const uint64_t k_sqlite3_prepare = 0x2896590;
const uint64_t k_sqlite3_open = 0x28cdd90;
const uint64_t k_sqlite3_step = 0x2852a20;
const uint64_t k_sqlite3_column_count = 0x2853240;
const uint64_t k_sqlite3_column_name = 0x2853c40;
const uint64_t k_sqlite3_column_type = 0x2853a90;
const uint64_t k_sqlite3_column_blob = 0x2853270;
const uint64_t k_sqlite3_column_bytes = 0x2853360;
const uint64_t k_sqlite3_finalize = 0x2851ad0;
const uint64_t k_sqlite3_exec = 0x3afba50;
const uint64_t k_sqlite3_prepare = 0x3b036d0;
const uint64_t k_sqlite3_open = 0x3b3aec0;
const uint64_t k_sqlite3_step = 0x3abfa50;
const uint64_t k_sqlite3_column_count = 0x3ac0270;
const uint64_t k_sqlite3_column_name = 0x3ac0c70;
const uint64_t k_sqlite3_column_type = 0x3ac0ac0;
const uint64_t k_sqlite3_column_blob = 0x3ac02a0;
const uint64_t k_sqlite3_column_bytes = 0x3ac0390;
const uint64_t k_sqlite3_finalize = 0x3abeb00;
const uint64_t kGPInstance = 0x4076558;
const uint64_t kMicroMsgDB = 0xb8;
const uint64_t kChatMsgDB = 0x2c8;
const uint64_t kMiscDB = 0x5f0;
const uint64_t kEmotionDB = 0x888;
const uint64_t kMediaDB = 0xF48;
const uint64_t kBizchatMsgDB = 0x1AC0;
const uint64_t kFunctionMsgDB = 0x1b98;
const uint64_t kDBName = 0x28;
const uint64_t kStorageStart = 0x0;
const uint64_t kStorageEnd = 0x0;
const uint64_t kMultiDBMgr = 0x40ecf98;
const uint64_t kPublicMsgMgr = 0x40ea558;
const uint64_t kFavoriteStorageMgr = 0x40edb28;
const uint64_t kHardLinkMgr = 0x40ecec0;
const uint64_t kGPInstance = 0x5a415a0;
const uint64_t kMultiDBMgr = 0x5abc5c8;
const uint64_t kPublicMsgMgr = 0x5ab9b68;
const uint64_t kFavoriteStorageMgr = 0x5abd178;
const uint64_t kHardLinkMgr = 0x5abc4e8;
const uint64_t kChatRoomMgr = 0x8e9d30;
const uint64_t kGetChatRoomDetailInfo = 0xe73590;
const uint64_t kNewChatRoomInfo = 0x12006b0;
const uint64_t kFreeChatRoomInfo = 0x1200890;
const uint64_t kDoAddMemberToChatRoom = 0xe63c70;
const uint64_t kChatRoomMgr = 0x1c4e1e0;
const uint64_t kGetChatRoomDetailInfo = 0x222cf00;
const uint64_t kNewChatRoomInfo = 0x25d0250;
const uint64_t kFreeChatRoomInfo = 0x25d0430;
const uint64_t kDoAddMemberToChatRoom = 0x221c900;
const uint64_t kDoModChatRoomMemberNickName = 0xe6db00;
const uint64_t kDelMemberFromChatRoom = 0xe64290;
const uint64_t kGetMemberFromChatRoom = 0xe74de0;
const uint64_t kNewChatRoom = 0x11fde50;
const uint64_t kFreeChatRoom = 0x11fe030;
const uint64_t kDelMemberFromChatRoom = 0x221cf40;
const uint64_t kGetMemberFromChatRoom = 0x222e750;
const uint64_t kNewChatRoom = 0x25cd670;
const uint64_t kFreeChatRoom = 0x25cd870;
const uint64_t kTopMsg = 0xa5e4f0;
const uint64_t kRemoveTopMsg = 0xe787b0;

View File

@ -385,12 +385,70 @@ int64_t wechat::WeChatService::GetContacts(std::vector<ContactInner>& vec) {
int64_t wechat::WeChatService::GetChatRoomDetailInfo(
const std::wstring& room_id, ChatRoomInfoInner& room_info) {
return 0;
int64_t success = -1;
prototype::WeChatString chat_room_id(room_id);
int64_t base_addr = wxutils::GetWeChatWinBase();
uint64_t get_chat_room_mgr_addr = base_addr + offset::kChatRoomMgr;
uint64_t get_chat_room_detail_addr = base_addr + offset::kGetChatRoomDetailInfo;
uint64_t create_chat_room_info_addr = base_addr + offset::kNewChatRoomInfo;
uint64_t free_chat_room_info_addr = base_addr + offset::kFreeChatRoomInfo;
func::__GetChatRoomMgr get_chat_room_mgr = (func::__GetChatRoomMgr)get_chat_room_mgr_addr;
func::__NewChatRoomInfo new_chat_room_info = (func::__NewChatRoomInfo)create_chat_room_info_addr;
func::__FreeChatRoomInfo free_chat_room_info = (func::__FreeChatRoomInfo)free_chat_room_info_addr;
func::__GetChatRoomDetailInfo get_chat_room_detail = (func::__GetChatRoomDetailInfo)get_chat_room_detail_addr;
char chat_room_info[0x144] = {0};
uint64_t new_room_info = new_chat_room_info(reinterpret_cast<uint64_t>(&chat_room_info));
uint64_t mgr = get_chat_room_mgr();
success = get_chat_room_detail(mgr,reinterpret_cast<uint64_t>(&chat_room_id),new_room_info,1);
room_info.chat_room_id = wxutils::ReadWstringThenConvert(new_room_info + 0x8);
room_info.notice = wxutils::ReadWstringThenConvert(new_room_info + 0x28);
room_info.admin = wxutils::ReadWstringThenConvert(new_room_info + 0x48);
room_info.xml = wxutils::ReadWstringThenConvert(new_room_info + 0x78);
free_chat_room_info(new_room_info);
return success;
}
int64_t wechat::WeChatService::AddMemberToChatRoom(
const std::wstring& room_id, const std::vector<std::wstring>& members) {
return 0;
int64_t success = -1;
uint64_t get_chat_room_mgr_addr = base_addr_ + offset::kChatRoomMgr;
uint64_t add_members_addr = base_addr_ + offset::kDoAddMemberToChatRoom;
func::__GetChatRoomMgr get_chat_room_mgr =
(func::__GetChatRoomMgr)get_chat_room_mgr_addr;
func::__DoAddMemberToChatRoom add_members =
(func::__DoAddMemberToChatRoom)add_members_addr;
prototype::WeChatString *chat_room_id = (prototype::WeChatString *)HeapAlloc(
GetProcessHeap(), 0, sizeof(prototype::WeChatString));
wchar_t *p_chat_room_id =
(wchar_t *)HeapAlloc(GetProcessHeap(), 0, (room_id.size() + 1) * 2);
wmemcpy(p_chat_room_id, room_id.c_str(), room_id.size() + 1);
chat_room_id->ptr = p_chat_room_id;
chat_room_id->length = static_cast<int32_t>(room_id.size());
chat_room_id->max_length = static_cast<int32_t>(room_id.size());
chat_room_id->c_len = 0;
chat_room_id->c_ptr = 0;
std::vector<prototype::WeChatString> member_list;
uint64_t temp[2] = {0};
wechat::VectorInner *list = (wechat::VectorInner *)&member_list;
int64_t members_ptr = (int64_t)&list->start;
for (int i = 0; i < members.size(); i++) {
prototype::WeChatString member(members[i]);
member_list.push_back(member);
}
uint64_t mgr = get_chat_room_mgr();
success =
add_members(mgr, members_ptr, reinterpret_cast<uint64_t>(chat_room_id),
reinterpret_cast<uint64_t>(&temp));
return success;
}
int64_t wechat::WeChatService::ModChatRoomMemberNickName(
@ -401,12 +459,56 @@ int64_t wechat::WeChatService::ModChatRoomMemberNickName(
int64_t wechat::WeChatService::DelMemberFromChatRoom(
const std::wstring& room_id, const std::vector<std::wstring>& members) {
return 0;
int64_t success = -1;
uint64_t get_chat_room_mgr_addr = base_addr_ + offset::kChatRoomMgr;
uint64_t del_members_addr = base_addr_ + offset::kDelMemberFromChatRoom;
func::__GetChatRoomMgr get_chat_room_mgr =
(func::__GetChatRoomMgr)get_chat_room_mgr_addr;
func::__DoDelMemberFromChatRoom del_members =
(func::__DoDelMemberFromChatRoom)del_members_addr;
prototype::WeChatString* chat_room_id = BuildWechatString(room_id);
std::vector<prototype::WeChatString> member_list;
uint64_t temp[2] = {0};
wechat::VectorInner* list = (wechat::VectorInner*)&member_list;
int64_t members_ptr = (int64_t)&list->start;
for (int i = 0; i < members.size(); i++) {
prototype::WeChatString member(members[i]);
member_list.push_back(member);
}
uint64_t mgr = get_chat_room_mgr();
success =
del_members(mgr, members_ptr, reinterpret_cast<uint64_t>(chat_room_id));
return success;
}
int64_t wechat::WeChatService::GetMemberFromChatRoom(
const std::wstring& room_id, ChatRoomMemberInner& member) {
return 0;
int64_t success = -1;
uint64_t get_chat_room_mgr_addr = base_addr_ + offset::kChatRoomMgr;
uint64_t get_members_addr = base_addr_ + offset::kGetMemberFromChatRoom;
uint64_t new_chat_room_addr = base_addr_ + offset::kNewChatRoom;
uint64_t free_chat_room_addr = base_addr_ + offset::kFreeChatRoom;
func::__GetChatRoomMgr get_chat_room_mgr =
(func::__GetChatRoomMgr)get_chat_room_mgr_addr;
func::__GetMemberFromChatRoom get_members =
(func::__GetMemberFromChatRoom)get_members_addr;
func::__NewChatRoom new_chat_room = (func::__NewChatRoom)new_chat_room_addr;
func::__FreeChatRoom free_chat_room =
(func::__FreeChatRoom)free_chat_room_addr;
prototype::WeChatString chat_room_id(room_id);
char chat_room_info[0x308] = {0};
uint64_t addr = new_chat_room(reinterpret_cast<uint64_t>(&chat_room_info));
uint64_t mgr = get_chat_room_mgr();
success = get_members(mgr, reinterpret_cast<uint64_t>(&chat_room_id), addr);
member.chat_room_id = wxutils::ReadWstringThenConvert(addr + 0x10);
member.admin = wxutils::ReadWstringThenConvert(addr + 0x78);
member.member_nickname = wxutils::ReadWstringThenConvert(addr + 0x50);
member.admin_nickname = wxutils::ReadWstringThenConvert(addr + 0xA0);
member.member = wxutils::ReadWeChatStr(addr + 0x30);
free_chat_room(addr);
return success;
}
int64_t wechat::WeChatService::SetTopMsg(uint64_t msg_id) { return 0; }