Merge pull request #225 from ttttupup/dev-3.9.5.81

Dev 3.9.5.81
This commit is contained in:
ttttupup 2023-07-22 09:19:20 +08:00 committed by GitHub
commit 51a4693330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 147 additions and 1 deletions

View File

@ -736,4 +736,94 @@ enableHttp=0时使用ipport的tcp服务回传消息。
},
"msg": "success"
}
```
#### 14.置顶群消息**
###### 接口功能
> 置顶群消息,需要群主权限
###### 接口地址
> [/api/topMsg](/api/topMsg)
###### HTTP请求方式
> POST JSON
###### 请求参数
|参数|必选|类型|说明|
|---|---|---|---|
|msgId |true |string| 消息id |
###### 返回字段
|返回字段|字段类型|说明 |
|---|---|---|
|code|int|返回状态,1成功, -1失败|
|msg|string|成功提示|
|data|object|null|
###### 接口示例
入参:
``` javascript
{
"msgId":8005736725060623215
}
```
响应:
``` javascript
{
"code": 1,
"data": null,
"msg": "success"
}
```
#### 15.移除置顶群消息**
###### 接口功能
> 移除置顶群消息,需要群主权限
###### 接口地址
> [/api/removeTopMsg](/api/removeTopMsg)
###### HTTP请求方式
> POST JSON
###### 请求参数
|参数|必选|类型|说明|
|---|---|---|---|
|msgId |true |string| 消息id |
|chatRoomId |true |string| 群id |
###### 返回字段
|返回字段|字段类型|说明 |
|---|---|---|
|code|int|返回状态,1成功, -1失败|
|msg|string|成功提示|
|data|object|null|
###### 接口示例
入参:
``` javascript
{
"msgId":8005736725060623215
"chatRoomId":"12345678@chatroom"
}
```
响应:
``` javascript
{
"code": 1,
"data": null,
"msg": "success"
}
```

View File

@ -344,6 +344,7 @@ std::vector<void *> DB::GetDbHandles() {
msg0_db.db_name = (wchar_t *)(*(UINT64 *)(db_addr));
msg0_db.db_name_len = *(DWORD *)(db_addr + 0x8);
msg0_db.handle = msg0_db_addr;
msg0_db.extrainfo = *(UINT64 *)(*(UINT64 *)(db_addr + 0x28) + 0x1E8);
ExecuteSQL(msg0_db_addr,
"select * from sqlite_master where type=\"table\";",
(UINT64)GetDbInfo, &msg0_db);
@ -458,7 +459,7 @@ std::vector<std::string> DB::GetChatMsgByMsgId(ULONG64 msgid) {
wchar_t dbname[20] = {0};
for (int i = 0;; i++) {
swprintf_s(dbname, L"MSG%d.db", i);
DWORD handle = GetDbHandleByDbName(dbname);
UINT64 handle = GetDbHandleByDbName(dbname);
if (handle == 0) {
// LOG(INFO) << "MSG db handle is null";
return {};

View File

@ -341,6 +341,23 @@ std::string HttpDispatch(struct mg_connection *c, struct mg_http_message *hm) {
}
ret = ret_data.dump();
return ret;
} else if (mg_http_match_uri(hm, "/api/topMsg")) {
INT64 msg_id = GetINT64Param(j_param, "msgId");
INT64 success =
wxhelper::GlobalContext::GetInstance().mgr->SetTopMsg(msg_id);
nlohmann::json ret_data = {
{"code", success}, {"msg", "success"}, {"data", {}}};
ret = ret_data.dump();
return ret;
} else if (mg_http_match_uri(hm, "/api/removeTopMsg")) {
std::wstring room_id = GetWStringParam(j_param, "chatRoomId");
INT64 msg_id = GetINT64Param(j_param, "msgId");
INT64 success =
wxhelper::GlobalContext::GetInstance().mgr->RemoveTopMsg(room_id,msg_id);
nlohmann::json ret_data = {
{"code", success}, {"msg", "success"}, {"data", {}}};
ret = ret_data.dump();
return ret;
} else {
nlohmann::json ret_data = {
{"code", 200}, {"data", {}}, {"msg", "not support url"}};

View File

@ -3,6 +3,7 @@
#include "export.h"
#include "wechat_function.h"
#include "db.h"
namespace offset = wxhelper::V3_9_5_81::offset;
namespace prototype = wxhelper::V3_9_5_81::prototype;
@ -500,4 +501,33 @@ INT64 Manager::GetMemberFromChatRoom(const std::wstring &room_id,
free_chat_room(addr);
return success;
}
INT64 Manager::SetTopMsg(ULONG64 msg_id) {
INT64 success = -1;
UINT64 top_addr = base_addr_ + offset::kTopMsg;
func::__DoTopMsg top_msg = (func::__DoTopMsg)top_addr;
INT64 index = 0;
INT64 local_id = DB::GetInstance().GetLocalIdByMsgId(msg_id, index);
if (local_id <= 0 || index >> 32 == 0) {
success = -2;
return success;
}
LARGE_INTEGER l;
l.HighPart = index >> 32;
l.LowPart = (DWORD)local_id;
UINT64 ptr = reinterpret_cast<UINT64>(&l);
success = top_msg(ptr, 1);
return success;
}
INT64 Manager::RemoveTopMsg(const std::wstring &room_id, ULONG64 msg_id) {
INT64 success = -1;
UINT64 remove_addr = base_addr_ + offset::kRemoveTopMsg;
func::__RemoveTopMsg remove_top_msg = (func::__RemoveTopMsg)remove_addr;
prototype::WeChatString *chat_room_id = BuildWechatString(room_id);
const wchar_t *w_room = room_id.c_str();
success = remove_top_msg(reinterpret_cast<UINT64>(w_room), msg_id,
reinterpret_cast<UINT64>(chat_room_id));
return success;
}
} // namespace wxhelper

View File

@ -25,6 +25,8 @@ class Manager {
const std::vector<std::wstring>& members);
INT64 GetMemberFromChatRoom(const std::wstring& room_id,
common::ChatRoomMemberInner& member);
INT64 SetTopMsg(ULONG64 msg_id);
INT64 RemoveTopMsg(const std::wstring& room_id,ULONG64 msg_id);
private:
UINT64 base_addr_;

View File

@ -233,6 +233,8 @@ typedef UINT64 (*__GetMemberFromChatRoom)(UINT64,UINT64,UINT64);
typedef UINT64 (*__NewChatRoom)(UINT64);
typedef UINT64 (*__FreeChatRoom)(UINT64);
typedef UINT64 (*__DoTopMsg)(UINT64,UINT64);
typedef UINT64 (*__RemoveTopMsg)(UINT64,UINT64,UINT64);
} // namespace function
namespace prototype {
@ -329,6 +331,10 @@ const UINT64 kDelMemberFromChatRoom = 0xe64290;
const UINT64 kGetMemberFromChatRoom = 0xe74de0;
const UINT64 kNewChatRoom = 0x11fde50;
const UINT64 kFreeChatRoom = 0x11fe030;
const UINT64 kTopMsg = 0xa5e4f0;
const UINT64 kRemoveTopMsg = 0xe787b0;
} // namespace offset
} // namespace V3_9_5_81