Merge pull request #373 from sglmsn/main

适配3.9.8.25部分接口
This commit is contained in:
ttttupup 2024-03-08 17:02:54 +08:00 committed by GitHub
commit e4656e5139
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 72 additions and 28 deletions

View File

@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.0</version>
<version>3.2.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
@ -14,7 +14,8 @@
<name>wxhk</name>
<description>wxhk</description>
<properties>
<java.version>17</java.version>
<java.version>21</java.version>
<vertx-web-client.version>4.5.3</vertx-web-client.version>
</properties>
<dependencies>
<dependency>
@ -39,7 +40,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.92.Final</version>
<version>4.1.105.Final</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
@ -50,22 +51,22 @@
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>4.4.2</version>
<version>${vertx-web-client.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
<version>4.4.2</version>
<version>${vertx-web-client.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-client</artifactId>
<version>4.4.2</version>
<version>${vertx-web-client.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-mysql-client</artifactId>
<version>4.4.2</version>
<version>${vertx-web-client.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -42,6 +42,11 @@ public class PrivateChatMsg implements Serializable {
private String signature;
private String time;
private Integer timestamp;
/**
* 对用户,如果是文件助手是filehelper
*/
private String toUser;
/**
* 类型
*/

View File

@ -15,4 +15,17 @@ import lombok.experimental.Accessors;
public class OpenHook implements SendMsg<OpenHook> {
String port;
String ip;
/**
* 0/1 1.启用http 0.不启用http
*/
boolean enableHttp;
/**
* 超时时间,单位ms
*/
String timeout;
/**
* http的请求地址enableHttp=1时不能为空
*/
String url;
}

View File

@ -18,6 +18,7 @@ import org.w3c.dom.NodeList;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@ -50,7 +51,12 @@ public class WxMsgHandle {
@PostConstruct
public void init() {
add(chatMsg -> {
wxSmgServer.私聊(chatMsg);
if(Objects.equals(chatMsg.getToUser(), FILEHELPER)){
wxSmgServer.文件助手(chatMsg);
}else{
wxSmgServer.私聊(chatMsg);
}
return null;
}, WxMsgType.私聊信息);
add(chatMsg -> {
@ -174,8 +180,8 @@ public class WxMsgHandle {
if (monery.startsWith("")) {
String substring = monery.substring(1);
BigDecimal decimal = new BigDecimal(substring);
log.info("收款:{},付款人:{},付款备注:{}", decimal.stripTrailingZeros().toPlainString(), chatMsg.getFromUser(), remark);
wxSmgServer.收款之后(new PayoutInformation(chatMsg.getFromUser(), decimal, remark));
log.info("收款:{},付款人:{},付款备注:{}", decimal.stripTrailingZeros().toPlainString(), receiver_username, remark);
wxSmgServer.收款之后(new PayoutInformation(receiver_username, decimal, remark));
return false;
};

View File

@ -32,12 +32,14 @@ public class WxSmgServerImpl implements com.example.wxhk.server.WxSmgServer {
public void 私聊(PrivateChatMsg chatMsg) {
if (Objects.equals(chatMsg.getIsSendMsg(), 1) && Objects.equals(chatMsg.getIsSendByPhone(), 1)) {
log.info("手机端对:{}发出:{}", chatMsg.getFromUser(), chatMsg.getContent());
}else{
log.info("收到私聊{}",chatMsg);
}
}
@Override
public void 文件助手(PrivateChatMsg chatMsg) {
log.info("文件助手:{}",chatMsg);
}
@Override

View File

@ -2,7 +2,8 @@ package com.example.wxhk.tcp.vertx;
import com.example.wxhk.WxhkApplication;
import com.example.wxhk.constant.WxMsgType;
import com.example.wxhk.util.HttpAsyncUtil;
import com.example.wxhk.model.request.OpenHook;
import com.example.wxhk.util.HttpSendUtil;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Future;
@ -75,7 +76,10 @@ public class VertxTcp extends AbstractVerticle implements CommandLineRunner {
listen.onComplete(event -> {
boolean succeeded = event.succeeded();
if (succeeded) {
HttpAsyncUtil.exec(HttpAsyncUtil.Type.开启hook, new JsonObject().put("port", InitWeChat.getVertxPort().toString()).put("ip", "127.0.0.1"));
HttpSendUtil.开启hook(new OpenHook().setPort(InitWeChat.getVertxPort().toString()).setIp("127.0.0.1")
.setEnableHttp(false)
.setTimeout("5000"));
// HttpAsyncUtil.exec(HttpAsyncUtil.Type.开启hook, new JsonObject().put("port", InitWeChat.getVertxPort().toString()).put("ip", "127.0.0.1"));
startPromise.complete();
} else {
startPromise.fail(event.cause());

View File

@ -24,7 +24,7 @@ public class HttpAsyncUtil {
protected static final Log log = Log.get();
public static Future<HttpResponse<Buffer>> exec(Type type, JsonObject object) {
return client.post(InitWeChat.wxPort, "localhost", "/api/?type=" + type.getType())
return client.post(InitWeChat.wxPort, "localhost", "/api/" + type.getType())
.sendJsonObject(object)
.onSuccess(event ->
{
@ -36,7 +36,7 @@ public class HttpAsyncUtil {
}
public static Future<HttpResponse<Buffer>> exec(Type type, JsonObject object, Handler<AsyncResult<HttpResponse<Buffer>>> handler) {
return client.post(InitWeChat.wxPort, "localhost", "/api/?type=" + type.getType())
return client.post(InitWeChat.wxPort, "localhost", "/api/" + type.getType())
.sendJsonObject(object)
.onComplete(handler)
;
@ -45,22 +45,31 @@ public class HttpAsyncUtil {
}
public enum Type {
检查微信登陆("0"),
获取登录信息("1"),
发送文本("2"),
发送at文本("3"),
检查微信登陆("checkLogin"),
获取登录信息("userInfo"),
发送文本("sendTextMsg"),
转发消息("forwardMsg"),
发送at文本("sendAtText"),
发送图片("5"),
发送文件("6"),
开启hook("9"),
关闭hook("10"),
发送文件("sendFileMsg"),
开启hook("hookSyncMsg"),
关闭hook("unhookSyncMsg"),
添加好友("20"),
通过好友申请("23"),
获取群成员("25"),
获取群成员昵称("26"),
删除群成员("27"),
获取群成员("getMemberFromChatRoom"),
获取群成员基础信息("getContactProfile"),
获取群详情("getChatRoomDetailInfo"),
添加群成员("addMemberToChatRoom"),
修改群昵称("modifyNickname"),
删除群成员("delMemberFromChatRoom"),
置顶群消息("topMsg"),
取消置顶群消息("removeTopMsg"),
邀请入群("InviteMemberToChatRoom"),
确认收款("45"),
联系人列表("46"),
联系人列表("getContactList"),
查询微信信息("55"),
下载附件("downloadAttach"),
解码("decodeImage"),
;

View File

@ -27,7 +27,7 @@ public class HttpSyncUtil {
}
public static JsonObject exec(HttpAsyncUtil.Type type, JsonObject obj) {
String post = engine.send(Request.of("http://localhost:" + InitWeChat.wxPort + "/api/?type=" + type.getType()).method(Method.POST).body(obj.encode())).bodyStr();
String post = engine.send(Request.of("http://localhost:" + InitWeChat.wxPort + "/api/" + type.getType()).method(Method.POST).body(obj.encode())).bodyStr();
if (log.isDebugEnabled()) {
log.debug("type:{},{}", type.getType(), post);
}

View File

@ -1,4 +1,4 @@
wx.path=D:\\Program Files (x86)\\Tencent\\WeChat\\[3.9.2.23]\\WeChat.exe
wx.path=D:\\Program Files (x86)\\Tencent\\WeChat\\WeChat.exe
wx.port=19088
spring.profiles.active=local
vertx.port=8080

View File

@ -7,6 +7,8 @@ import org.dromara.hutool.core.lang.Console;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;
@SpringBootTest
@ -41,5 +43,7 @@ class HttpSendUtilTest {
void 获取群成员() {
GroupMembers 获取群成员 = HttpSendUtil.获取群成员(new GetGroupMembers().setChatRoomId("24964676359@chatroom"));
Console.log(获取群成员);
Duration between = Duration.between(LocalDateTime.now(), LocalDateTime.now());
}
}