From 292b9da378ff0d276c62f48035c70a4a78d67160 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=8E=8B=E6=B6=9B?= <2450572350@qq.com>
Date: Thu, 1 Jun 2023 16:58:29 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E6=9E=90=E5=90=8D=E7=89=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../main/java/com/example/wxhk/msg/WxMsgHandle.java | 10 ++++++++++
.../src/test/java/com/example/wxhk/tcp/XmlTest.java | 12 ++++++++++++
2 files changed, 22 insertions(+)
diff --git a/java_client/src/main/java/com/example/wxhk/msg/WxMsgHandle.java b/java_client/src/main/java/com/example/wxhk/msg/WxMsgHandle.java
index 0f99519..a2872cb 100644
--- a/java_client/src/main/java/com/example/wxhk/msg/WxMsgHandle.java
+++ b/java_client/src/main/java/com/example/wxhk/msg/WxMsgHandle.java
@@ -43,6 +43,16 @@ public class WxMsgHandle {
}
return 1;
}, WxMsgType.收到转账之后或者文件助手等信息);
+ add(chatMsg -> {
+ if("filehelper".equals(chatMsg.getFromUser())){
+ Document document = XmlUtil.parseXml(chatMsg.getContent());
+ Element documentElement = document.getDocumentElement();
+ String username = documentElement.getAttribute("username");
+ String alias = documentElement.getAttribute("alias");
+ HttpSendUtil.发送文本(username);
+ }
+ return 1;
+ }, WxMsgType.收到名片);
add(chatMsg -> {
HttpSendUtil.通过好友请求(chatMsg);
return 1;
diff --git a/java_client/src/test/java/com/example/wxhk/tcp/XmlTest.java b/java_client/src/test/java/com/example/wxhk/tcp/XmlTest.java
index e4bf159..a26aeef 100644
--- a/java_client/src/test/java/com/example/wxhk/tcp/XmlTest.java
+++ b/java_client/src/test/java/com/example/wxhk/tcp/XmlTest.java
@@ -69,4 +69,16 @@ public class XmlTest {
WxMsgHandle.解析扫码支付第二段(new JsonObject(smg).mapTo(PrivateChatMsg.class));
}
+
+
+ @Test
+ void 解析名片(){
+ String con = "{\"content\":\"\\n\\n\",\"fromGroup\":\"filehelper\",\"fromUser\":\"filehelper\",\"isSendByPhone\":1,\"isSendMsg\":1,\"msgId\":3235211232446491438,\"pid\":21868,\"sign\":\"bfb1db52fe99dc947586af50e6964c37\",\"signature\":\"\\n\\tv1_aebFg5gw\\n\\t\\n\\t\\t<![CDATA[]]>\\n\\t\\n\\n\",\"time\":\"2023-06-01 16:48:39\",\"timestamp\":1685609319,\"type\":42}";
+ PrivateChatMsg privateChatMsg = new JsonObject(con).mapTo(PrivateChatMsg.class);
+ Document document = XmlUtil.parseXml(privateChatMsg.getContent());
+ Element documentElement = document.getDocumentElement();
+ String username = documentElement.getAttribute("username");
+ String alias = documentElement.getAttribute("alias");
+ Console.log(alias,username);
+ }
}