mirror of
https://gitee.com/hotlcc/wechat4j.git
synced 2025-06-19 00:36:58 +08:00
代码调整
This commit is contained in:
parent
cc98ea74b1
commit
430b18b32a
6
pom.xml
6
pom.xml
@ -85,6 +85,12 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.16.20</version>
|
<version>1.16.20</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>4.6.4</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -1,12 +1,27 @@
|
|||||||
package com.hotlcc.wechat4j;
|
package com.hotlcc.wechat4j;
|
||||||
|
|
||||||
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hotlcc.wechat4j.enums.*;
|
import com.hotlcc.wechat4j.enums.ExitType;
|
||||||
|
import com.hotlcc.wechat4j.enums.LoginTip;
|
||||||
|
import com.hotlcc.wechat4j.enums.MediaType;
|
||||||
|
import com.hotlcc.wechat4j.enums.MsgType;
|
||||||
|
import com.hotlcc.wechat4j.enums.Retcode;
|
||||||
|
import com.hotlcc.wechat4j.enums.Selector;
|
||||||
import com.hotlcc.wechat4j.handler.ExitEventHandler;
|
import com.hotlcc.wechat4j.handler.ExitEventHandler;
|
||||||
import com.hotlcc.wechat4j.handler.ReceivedMsgHandler;
|
import com.hotlcc.wechat4j.handler.ReceivedMsgHandler;
|
||||||
import com.hotlcc.wechat4j.model.*;
|
import com.hotlcc.wechat4j.model.BaseRequest;
|
||||||
import com.hotlcc.wechat4j.util.*;
|
import com.hotlcc.wechat4j.model.MediaMessage;
|
||||||
|
import com.hotlcc.wechat4j.model.ReceivedMsg;
|
||||||
|
import com.hotlcc.wechat4j.model.UserInfo;
|
||||||
|
import com.hotlcc.wechat4j.model.WxMessage;
|
||||||
|
import com.hotlcc.wechat4j.util.FileUtil;
|
||||||
|
import com.hotlcc.wechat4j.util.PropertiesUtil;
|
||||||
|
import com.hotlcc.wechat4j.util.QRCodeUtil;
|
||||||
|
import com.hotlcc.wechat4j.util.StringUtil;
|
||||||
|
import com.hotlcc.wechat4j.util.WebWeixinApiUtil;
|
||||||
|
import com.hotlcc.wechat4j.util.WechatUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.http.HttpRequest;
|
import org.apache.http.HttpRequest;
|
||||||
import org.apache.http.HttpRequestInterceptor;
|
import org.apache.http.HttpRequestInterceptor;
|
||||||
@ -265,7 +280,7 @@ public class Wechat {
|
|||||||
pw.flush();
|
pw.flush();
|
||||||
getWxUuid(pw, 0);
|
getWxUuid(pw, 0);
|
||||||
|
|
||||||
CommonUtil.threadSleep(2000);
|
ThreadUtil.sleep(2000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +460,7 @@ public class Wechat {
|
|||||||
pw.println();
|
pw.println();
|
||||||
pw.flush();
|
pw.flush();
|
||||||
|
|
||||||
CommonUtil.threadSleep(2000);
|
ThreadUtil.sleep(2000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,7 +708,7 @@ public class Wechat {
|
|||||||
//如果时间太短则阻塞2秒
|
//如果时间太短则阻塞2秒
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
if (end - start < 2000) {
|
if (end - start < 2000) {
|
||||||
CommonUtil.threadSleep(2000);
|
ThreadUtil.sleep(2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
package com.hotlcc.wechat4j.util;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用工具类
|
|
||||||
*
|
|
||||||
* @author Allen
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public final class CommonUtil {
|
|
||||||
private CommonUtil() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 睡眠线程
|
|
||||||
*
|
|
||||||
* @param millis 时间
|
|
||||||
* @param nanos nanos
|
|
||||||
*/
|
|
||||||
public static void threadSleep(long millis, int nanos) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(millis, nanos);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 睡眠线程
|
|
||||||
*
|
|
||||||
* @param millis 时间
|
|
||||||
*/
|
|
||||||
public static void threadSleep(long millis) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(millis);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +1,9 @@
|
|||||||
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hotlcc.wechat4j.Wechat;
|
import com.hotlcc.wechat4j.Wechat;
|
||||||
import com.hotlcc.wechat4j.handler.ReceivedMsgHandler;
|
import com.hotlcc.wechat4j.handler.ReceivedMsgHandler;
|
||||||
import com.hotlcc.wechat4j.model.ReceivedMsg;
|
import com.hotlcc.wechat4j.model.ReceivedMsg;
|
||||||
import com.hotlcc.wechat4j.model.UserInfo;
|
import com.hotlcc.wechat4j.model.UserInfo;
|
||||||
import com.hotlcc.wechat4j.util.CommonUtil;
|
|
||||||
import com.hotlcc.wechat4j.util.StringUtil;
|
import com.hotlcc.wechat4j.util.StringUtil;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -38,13 +38,15 @@ public class TestClass {
|
|||||||
|
|
||||||
public void testSendImage() {
|
public void testSendImage() {
|
||||||
File file = null;
|
File file = null;
|
||||||
JSONObject result = null;
|
JSONObject result;
|
||||||
file = new File("C:\\Users\\Administrator\\Pictures\\壁纸\\9e5f4981099bcf351e0ec18c3654aced.jpg");
|
file = new File("C:\\Users\\Administrator\\Pictures\\壁纸\\9e5f4981099bcf351e0ec18c3654aced.jpg");
|
||||||
result = wechat.sendImageToUserName(null, file);
|
result = wechat.sendImageToUserName(null, file);
|
||||||
file = new File("C:\\Users\\Administrator\\Videos\\手机QQ视频_20190416170016.mp4");
|
file = new File("C:\\Users\\Administrator\\Videos\\手机QQ视频_20190416170016.mp4");
|
||||||
result = wechat.sendVideoToUserName(null, file);
|
result = wechat.sendVideoToUserName(null, file);
|
||||||
System.out.println(result);
|
System.out.println(result);
|
||||||
while (true) CommonUtil.threadSleep(5000);
|
while (true) {
|
||||||
|
ThreadUtil.sleep(5000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user