MCPcopy Create free account
hub / github.com/aixed/WeChat-Hook / Route_SendTextMsg

Function Route_SendTextMsg

src/SendTextMsg.cpp:9–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7using json = nlohmann::json;
8
9void Route_SendTextMsg(httplib::Server& svr)
10{
11 svr.Post("/SendTextMsg", [](const httplib::Request& req, httplib::Response& res)
12 {
13 json reqJson;
14 json resp;
15
16 try
17 {
18 reqJson = json::parse(req.body);
19 }
20 catch (...)
21 {
22 resp["ret"] = -1;
23 resp["msg"] = "invalid json";
24 res.set_content(resp.dump(), "application/json");
25 return;
26 }
27
28 std::string wxidorgid = reqJson.value("wxidorgid", "");
29 std::string msg = reqJson.value("msg", "");
30
31 WeixinSend::SendText(wxidorgid, msg);
32
33
34 resp["ret"] = 0;
35 resp["retmsg"] = "success";
36
37 res.set_content(resp.dump(), "application/json");
38 });
39
40 svr.Post("/Decode_Pic", [](const httplib::Request& req, httplib::Response& res)
41 {
42 json reqJson;
43 json resp;
44
45 try
46 {
47 reqJson = json::parse(req.body);
48 }
49 catch (...)
50 {
51 resp["ret"] = -1;
52 resp["msg"] = "invalid json";
53 res.set_content(resp.dump(), "application/json");
54 return;
55 }
56
57
58 std::string src_path = reqJson.value("src_path", "");
59 std::string dst_path = reqJson.value("dst_path", "");
60
61 OutputDebugStringA(("Decode_Pic src_path: " + src_path + "\n").c_str());
62 OutputDebugStringA(("Decode_Pic dst_path: " + dst_path + "\n").c_str());
63
64
65 WeixinSend::DecodePic(src_path, dst_path);
66

Callers 1

RegisterRoutesFunction · 0.85

Calls 7

SendTextFunction · 0.85
DecodePicFunction · 0.85
parseFunction · 0.50
PostMethod · 0.45
set_contentMethod · 0.45
dumpMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected