From 237c9273cab3ff3f2618d40c94ee7e9bfb984b08 Mon Sep 17 00:00:00 2001 From: Yutou <583819556@qq.com> Date: Mon, 3 Feb 2025 14:45:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(QQBot):=20=E6=9B=B4=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=B9=B6=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将版本号从 v.1.7.7 升级到 v.1.7.8 -重构 sendMessage 方法,支持发送包含图片和回复的消息 - 更新服务器版本查询 URL 为 HTTPS - 注释掉版本查询时的服务器消息发送 --- .../com/yutou/qqbot/QQBotApplication.java | 2 +- .../java/com/yutou/qqbot/QQBotManager.java | 29 ++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/yutou/qqbot/QQBotApplication.java b/src/main/java/com/yutou/qqbot/QQBotApplication.java index 8a93256..b3e95e1 100644 --- a/src/main/java/com/yutou/qqbot/QQBotApplication.java +++ b/src/main/java/com/yutou/qqbot/QQBotApplication.java @@ -10,7 +10,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class QQBotApplication { - public static final String version = "QQBot v.1.7.7"; + public static final String version = "QQBot v.1.7.8"; public static void main(String[] args) { System.out.println("version = " + version); diff --git a/src/main/java/com/yutou/qqbot/QQBotManager.java b/src/main/java/com/yutou/qqbot/QQBotManager.java index 249b1bc..5e12b8b 100644 --- a/src/main/java/com/yutou/qqbot/QQBotManager.java +++ b/src/main/java/com/yutou/qqbot/QQBotManager.java @@ -3,10 +3,7 @@ package com.yutou.qqbot; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.yutou.napcat.QQDatabase; -import com.yutou.napcat.handle.BaseHandle; -import com.yutou.napcat.handle.MessageHandleBuild; -import com.yutou.napcat.handle.Reply; -import com.yutou.napcat.handle.Text; +import com.yutou.napcat.handle.*; import com.yutou.napcat.http.NapCatApi; import com.yutou.napcat.model.FriendBean; import com.yutou.napcat.model.GroupBean; @@ -22,6 +19,7 @@ import retrofit2.Response; import java.io.File; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -166,7 +164,7 @@ public class QQBotManager { public String sendMessage(String text) { - return getNotLoginQQ(); + return sendMessage(false,defGroup,text).toString(); } public SendMessageResponse sendMessage(Long group, String text) { @@ -186,10 +184,27 @@ public class QQBotManager { } public void sendMessage(File imageFile, Long qq, String replyMessageId, String text) { + List> items = new ArrayList<>(); + if (imageFile != null) { + items.add(new Image(imageFile)); + } + + if (replyMessageId != null && !replyMessageId.isEmpty()) { + items.add(new Reply(Long.parseLong(replyMessageId))); + } + + if (text != null && !text.isEmpty()) { + items.add(new Text(text)); + } + + if (!items.isEmpty()) { + sendMessage(QQDatabase.checkFriend(qq),qq, items); + } } public void sendMessage(File imageFile, String text) { + sendMessage(true,defQQ,new Image(imageFile),new Text(text)); } public void sendMessage(List imgs, Long qq, String text) { @@ -248,10 +263,10 @@ public class QQBotManager { public void sendVersion() { String localVersion = QQBotApplication.version; - String serverVersion = HttpTools.get("http://tools.yutou233.cn:8000/public/version.do?token=zIrsh9TUZP2lfRW753PannG49E7VJvor"); + String serverVersion = HttpTools.get("https://tools.yutou233.cn/public/version.do?token=zIrsh9TUZP2lfRW753PannG49E7VJvor"); String msg = "本地版本:" + localVersion + "\n" + "服务器版本:" + serverVersion; QQBotManager.getInstance().sendMessage(msg); - AppTools.sendServer("服务版本查询", msg); + // AppTools.sendServer("服务版本查询", msg); } public boolean isLogin() {