From 6d254c5f82df0238830e4548562fb105257f1fd1 Mon Sep 17 00:00:00 2001 From: hugy <504650082@qq.com> Date: Thu, 8 Jun 2023 00:29:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=A5=BD=E5=8F=8B?= =?UTF-8?q?=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/3.9.2.23.md | 43 +++++++++++++++++++++++++++++++++++++++++++ src/api_route.h | 1 + src/contact_mgr.cc | 20 ++++++++++++++++++++ src/contact_mgr.h | 1 + src/http_handler.cc | 8 ++++++++ src/wechat_function.h | 1 + 6 files changed, 74 insertions(+) diff --git a/doc/3.9.2.23.md b/doc/3.9.2.23.md index 543a5dc..1e23bc1 100644 --- a/doc/3.9.2.23.md +++ b/doc/3.9.2.23.md @@ -50,6 +50,7 @@ 64.发送小程序 65.退款 66.下载头像 +67.修改好友备注 ### 接口文档: @@ -2007,6 +2008,48 @@ ``` + +#### 67.修改好友备注** +###### 接口功能 +> 修改好友备注 + +###### 接口地址 +> [/api/?type=67](/api/?type=67) + +###### HTTP请求方式 +> POST JSON + +###### 请求参数 +|参数|必选|类型|说明| +|---|---|---|---| +|wxid|string|微信id| +|remark|string|备注内容| + + +###### 返回字段 +|返回字段|字段类型|说明 | +|---|---|---| +|code|int|返回状态,1成功| +|result|string|成功提示| + + + + +###### 接口示例 +入参: +``` javascript +{ + "wxid":"wxid_agz5q76f11112", + "remark":"123" +} +``` +响应: +``` javascript +{"code":1,"result":"OK"} +``` + + + #### 感谢 https://github.com/ljc545w/ComWeChatRobot diff --git a/src/api_route.h b/src/api_route.h index 346ca94..8f9cbc8 100644 --- a/src/api_route.h +++ b/src/api_route.h @@ -80,6 +80,7 @@ typedef enum HTTP_API_ROUTE { WECHAT_SEND_APP_MSG, WECHAT_REFUSE, WECHAT_GET_HEAD_IMG, + WECHAT_MOD_CONTACT_REMARK, } WECHAT_HTTP_APIS, *PWECHAT_HTTP_APIS; diff --git a/src/contact_mgr.cc b/src/contact_mgr.cc index 6c0dcde..abd5f7a 100644 --- a/src/contact_mgr.cc +++ b/src/contact_mgr.cc @@ -285,4 +285,24 @@ int ContactMgr::AddFriendByWxid(wchar_t *wxid,wchar_t* msg) { success = 1; return success; } + + int ContactMgr::ModifyContactRemark(wchar_t* wxid,wchar_t* remark){ + int success = -1; + WeChatString contact(wxid); + WeChatString content(remark); + DWORD mod__addr = base_addr_ + WX_MOD_REMARK_OFFSET; + __asm{ + PUSHAD + PUSHFD + LEA EAX,content + PUSH EAX + LEA EAX,contact + PUSH EAX + CALL mod__addr + POPFD + POPAD + } + success = 1; + return success; + } } // namespace wxhelper \ No newline at end of file diff --git a/src/contact_mgr.h b/src/contact_mgr.h index b212495..f4d36d8 100644 --- a/src/contact_mgr.h +++ b/src/contact_mgr.h @@ -17,6 +17,7 @@ class ContactMgr : public BaseMgr { int VerifyApply(wchar_t *v3, wchar_t *v4,int permission); int GetContactByWxid(wchar_t* wxid,ContactProfile& profile); int GetHeadImage(wchar_t* wxid,wchar_t* url); + int ModifyContactRemark(wchar_t* wxid,wchar_t* remark); }; } // namespace wxhelper diff --git a/src/http_handler.cc b/src/http_handler.cc index 9375898..c372af5 100644 --- a/src/http_handler.cc +++ b/src/http_handler.cc @@ -677,6 +677,14 @@ string Dispatch(struct mg_connection *c, struct mg_http_message *hm) { ret = ret_data.dump(); break; } + case WECHAT_MOD_CONTACT_REMARK:{ + wstring wxid = GetWStringParam(j_param, "wxid"); + wstring remark = GetWStringParam(j_param, "remark"); + int success =g_context.contact_mgr->ModifyContactRemark(WS2LPWS(wxid), WS2LPWS(remark)); + json ret_data = {{"code", success}, {"result", "OK"}}; + ret = ret_data.dump(); + break; + } default: json ret_data = {{"result", "ERROR"}, {"msg", "not support api"}}; ret = ret_data.dump(); diff --git a/src/wechat_function.h b/src/wechat_function.h index 9223843..f1dc8ea 100644 --- a/src/wechat_function.h +++ b/src/wechat_function.h @@ -86,6 +86,7 @@ #define WX_VERIFY_OK_OFFSET 0xa18bd0 #define WX_NEW_ADD_FRIEND_HELPER_OFFSET 0xa17d50 #define WX_FREE_ADD_FRIEND_HELPER_OFFSET 0xa17e70 +#define WX_MOD_REMARK_OFFSET 0xbfd5e0 // pushAttachTask