更新FastJSON
调整ChromeDriver参数
This commit is contained in:
parent
4031b07b0b
commit
e0f81620a3
2
pom.xml
2
pom.xml
@ -60,7 +60,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.fastjson2</groupId>
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
<artifactId>fastjson2</artifactId>
|
<artifactId>fastjson2</artifactId>
|
||||||
<version>2.0.1</version>
|
<version>2.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.yutou.qqbot;
|
package com.yutou.qqbot;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONFactory;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.yutou.qqbot.Listeners.QQMessageListener;
|
import com.yutou.qqbot.Listeners.QQMessageListener;
|
||||||
import com.yutou.qqbot.MessageEvent.Message;
|
import com.yutou.qqbot.MessageEvent.Message;
|
||||||
import com.yutou.qqbot.models.Animal.TurnipProphet;
|
import com.yutou.qqbot.models.Animal.TurnipProphet;
|
||||||
@ -27,12 +30,13 @@ import net.mamoe.mirai.utils.ExternalResource;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class QQBotManager {
|
public class QQBotManager {
|
||||||
|
|
||||||
public static Long defGroup=891655174L;
|
public static Long defGroup = 891655174L;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Model.classList.add(QQSetu.class);
|
Model.classList.add(QQSetu.class);
|
||||||
@ -57,6 +61,7 @@ public class QQBotManager {
|
|||||||
Model.classList.add(BiliBiliMangeSign.class);
|
Model.classList.add(BiliBiliMangeSign.class);
|
||||||
Model.classList.add(Moyu.class);
|
Model.classList.add(Moyu.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static QQBotManager botManager = null;
|
private static QQBotManager botManager = null;
|
||||||
private Bot bot;
|
private Bot bot;
|
||||||
private static final long qqGroup = 891655174L;
|
private static final long qqGroup = 891655174L;
|
||||||
@ -77,8 +82,12 @@ public class QQBotManager {
|
|||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long qq = ConfigTools.load(ConfigTools.CONFIG,"qq_number",Long.class);
|
long qq = ConfigTools.load(ConfigTools.CONFIG, "qq_number", Long.class);
|
||||||
String password = ConfigTools.load(ConfigTools.CONFIG,"qq_password",String.class);
|
String password = ConfigTools.load(ConfigTools.CONFIG, "qq_password", String.class);
|
||||||
|
System.out.println("qq = " + qq);
|
||||||
|
System.out.println("password = " + password);
|
||||||
|
qq=3620756944L;
|
||||||
|
password="UAs6YBYMyxJU";
|
||||||
bot = BotFactory.INSTANCE.newBot(qq, password, new BotConfiguration() {
|
bot = BotFactory.INSTANCE.newBot(qq, password, new BotConfiguration() {
|
||||||
{
|
{
|
||||||
setProtocol(MiraiProtocol.ANDROID_PAD);
|
setProtocol(MiraiProtocol.ANDROID_PAD);
|
||||||
@ -91,7 +100,7 @@ public class QQBotManager {
|
|||||||
});
|
});
|
||||||
//Events.registerEvents(bot, new MessageListener());
|
//Events.registerEvents(bot, new MessageListener());
|
||||||
GlobalEventChannel.INSTANCE.registerListenerHost(new QQMessageListener());
|
GlobalEventChannel.INSTANCE.registerListenerHost(new QQMessageListener());
|
||||||
// GlobalEventChannel.INSTANCE.subscribeAlways(GroupMessageEvent.class, new MessageListener());
|
// GlobalEventChannel.INSTANCE.subscribeAlways(GroupMessageEvent.class, new MessageListener());
|
||||||
bot.login();
|
bot.login();
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -101,7 +110,7 @@ public class QQBotManager {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
String str = sendMessage("姬妻酱上线拉~☆Daze~ 当前版本:"+QQBotApplication.version);
|
String str = sendMessage("姬妻酱上线拉~☆Daze~ 当前版本:" + QQBotApplication.version);
|
||||||
Log.i(str);
|
Log.i(str);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -124,14 +133,14 @@ public class QQBotManager {
|
|||||||
return isLogin;
|
return isLogin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Image getImage(File file,Long qq) {
|
private Image getImage(File file, Long qq) {
|
||||||
if (bot != null) {
|
if (bot != null) {
|
||||||
ExternalResource resource=ExternalResource.create(file);
|
ExternalResource resource = ExternalResource.create(file);
|
||||||
Image image;
|
Image image;
|
||||||
if(QQNumberManager.getManager().isGroup(qq)) {
|
if (QQNumberManager.getManager().isGroup(qq)) {
|
||||||
image= Objects.requireNonNull(bot.getGroup(qq)).uploadImage(resource);
|
image = Objects.requireNonNull(bot.getGroup(qq)).uploadImage(resource);
|
||||||
}else{
|
} else {
|
||||||
image= Objects.requireNonNull(bot.getFriend(qq)).uploadImage(resource);
|
image = Objects.requireNonNull(bot.getFriend(qq)).uploadImage(resource);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resource.close();
|
resource.close();
|
||||||
@ -149,7 +158,7 @@ public class QQBotManager {
|
|||||||
|
|
||||||
|
|
||||||
public String sendMessage(String text) {
|
public String sendMessage(String text) {
|
||||||
if (bot != null&&!StringUtils.isEmpty(text)) {
|
if (bot != null && !StringUtils.isEmpty(text)) {
|
||||||
try {
|
try {
|
||||||
return Objects.requireNonNull(bot.getGroup(qqGroup)).sendMessage(text).toString();
|
return Objects.requireNonNull(bot.getGroup(qqGroup)).sendMessage(text).toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -162,9 +171,9 @@ public class QQBotManager {
|
|||||||
public String sendMessage(Long group, String text) {
|
public String sendMessage(Long group, String text) {
|
||||||
if (bot != null) {
|
if (bot != null) {
|
||||||
try {
|
try {
|
||||||
if(QQNumberManager.getManager().isGroup(group)) {
|
if (QQNumberManager.getManager().isGroup(group)) {
|
||||||
return Objects.requireNonNull(bot.getGroup(group)).sendMessage(text).toString();
|
return Objects.requireNonNull(bot.getGroup(group)).sendMessage(text).toString();
|
||||||
}else{
|
} else {
|
||||||
return Objects.requireNonNull(bot.getFriend(group)).sendMessage(text).toString();
|
return Objects.requireNonNull(bot.getFriend(group)).sendMessage(text).toString();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -176,31 +185,33 @@ public class QQBotManager {
|
|||||||
|
|
||||||
public void sendMessage(Long group, MessageChainBuilder builder) {
|
public void sendMessage(Long group, MessageChainBuilder builder) {
|
||||||
if (bot != null) {
|
if (bot != null) {
|
||||||
if(QQNumberManager.getManager().isGroup(group)) {
|
if (QQNumberManager.getManager().isGroup(group)) {
|
||||||
Objects.requireNonNull(bot.getGroup(group)).sendMessage(builder.asMessageChain());
|
Objects.requireNonNull(bot.getGroup(group)).sendMessage(builder.asMessageChain());
|
||||||
}else{
|
} else {
|
||||||
Objects.requireNonNull(bot.getFriend(group)).sendMessage(builder.asMessageChain());
|
Objects.requireNonNull(bot.getFriend(group)).sendMessage(builder.asMessageChain());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public String sendMessage(File imageFile,Long qq,String text){
|
|
||||||
return sendMessage(imageFile, qq,null, text);
|
public String sendMessage(File imageFile, Long qq, String text) {
|
||||||
|
return sendMessage(imageFile, qq, null, text);
|
||||||
}
|
}
|
||||||
public String sendMessage(File imageFile, Long qq, MessageChain replyMessage, String text){
|
|
||||||
|
public String sendMessage(File imageFile, Long qq, MessageChain replyMessage, String text) {
|
||||||
try {
|
try {
|
||||||
if (bot != null) {
|
if (bot != null) {
|
||||||
Image image = getImage(imageFile,qq);
|
Image image = getImage(imageFile, qq);
|
||||||
MessageChainBuilder builder = new MessageChainBuilder();
|
MessageChainBuilder builder = new MessageChainBuilder();
|
||||||
if(replyMessage!=null){
|
if (replyMessage != null) {
|
||||||
builder.append(new QuoteReply(replyMessage));
|
builder.append(new QuoteReply(replyMessage));
|
||||||
}
|
}
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
builder.append(image);
|
builder.append(image);
|
||||||
}
|
}
|
||||||
builder.append(text);
|
builder.append(text);
|
||||||
if(QQNumberManager.getManager().isGroup(qq)) {
|
if (QQNumberManager.getManager().isGroup(qq)) {
|
||||||
return Objects.requireNonNull(bot.getGroup(qq)).sendMessage(builder.asMessageChain()).toString();
|
return Objects.requireNonNull(bot.getGroup(qq)).sendMessage(builder.asMessageChain()).toString();
|
||||||
}else{
|
} else {
|
||||||
return Objects.requireNonNull(bot.getFriend(qq)).sendMessage(builder.asMessageChain()).toString();
|
return Objects.requireNonNull(bot.getFriend(qq)).sendMessage(builder.asMessageChain()).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,21 +221,22 @@ public class QQBotManager {
|
|||||||
|
|
||||||
return getNotLoginQQ();
|
return getNotLoginQQ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String sendMessage(File imageFile, String text) {
|
public String sendMessage(File imageFile, String text) {
|
||||||
return sendMessage(imageFile,qqGroup,text);
|
return sendMessage(imageFile, qqGroup, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String sendMessage(List<File> imgs,Long qq, String text) {
|
public String sendMessage(List<File> imgs, Long qq, String text) {
|
||||||
System.out.println("imgs.size() = " + imgs.size());
|
System.out.println("imgs.size() = " + imgs.size());
|
||||||
if (bot != null) {
|
if (bot != null) {
|
||||||
MessageChainBuilder builder = new MessageChainBuilder();
|
MessageChainBuilder builder = new MessageChainBuilder();
|
||||||
for (File img : imgs) {
|
for (File img : imgs) {
|
||||||
builder.append(Objects.requireNonNull(getImage(img,qq)));
|
builder.append(Objects.requireNonNull(getImage(img, qq)));
|
||||||
}
|
}
|
||||||
builder.append(text);
|
builder.append(text);
|
||||||
if(QQNumberManager.getManager().isGroup(qq)) {
|
if (QQNumberManager.getManager().isGroup(qq)) {
|
||||||
return Objects.requireNonNull(bot.getGroup(qq)).sendMessage(builder.asMessageChain()).toString();
|
return Objects.requireNonNull(bot.getGroup(qq)).sendMessage(builder.asMessageChain()).toString();
|
||||||
}else{
|
} else {
|
||||||
return Objects.requireNonNull(bot.getFriend(qq)).sendMessage(builder.asMessageChain()).toString();
|
return Objects.requireNonNull(bot.getFriend(qq)).sendMessage(builder.asMessageChain()).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,9 +244,14 @@ public class QQBotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
getInstance();
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("t1", 3234567890L);
|
||||||
|
System.out.println("json = " + json);
|
||||||
|
|
||||||
|
String tmp=json.toString();
|
||||||
|
JSONObject json2=JSON.parseObject(tmp);
|
||||||
|
System.out.println("json2 = " + json2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendVersion() {
|
public void sendVersion() {
|
||||||
|
@ -45,9 +45,10 @@ public class ConfigTools {
|
|||||||
String src = readFile(file);
|
String src = readFile(file);
|
||||||
if (src != null) {
|
if (src != null) {
|
||||||
try {
|
try {
|
||||||
JSONObject json = JSON.parseObject(src);
|
JSONObject json = JSONObject.parseObject(src,JSONObject.class);
|
||||||
return json.getObject(key, t);
|
return json.getObject(key, t);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ public class WebClient {
|
|||||||
private WebClient() {
|
private WebClient() {
|
||||||
System.setProperty("webdriver.chrome.driver",
|
System.setProperty("webdriver.chrome.driver",
|
||||||
ConfigTools.load(ConfigTools.CONFIG, "chrome", String.class));
|
ConfigTools.load(ConfigTools.CONFIG, "chrome", String.class));
|
||||||
|
System.setProperty("webdriver.chrome.whitelistedIps", "");
|
||||||
// java.util.logging.Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF);
|
// java.util.logging.Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user