From 731d7734d563af2396fe9d90d8d7ef34d5061d75 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Mon, 18 Apr 2022 23:13:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=91=B8=E9=B1=BC=E6=A8=A1=E5=9D=97=EF=BC=9A?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=8F=90=E5=89=8D=E4=B8=8B=E8=BD=BD=EF=BC=8C?= =?UTF-8?q?=E5=90=8E=E7=BB=AD=E5=86=8D=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yutou/qqbot/models/Commands/Moyu.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/yutou/qqbot/models/Commands/Moyu.java b/src/main/java/com/yutou/qqbot/models/Commands/Moyu.java index 05f8613..ce2bdc5 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/Moyu.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/Moyu.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.interfaces.DownloadInterface; import com.yutou.qqbot.models.Model; +import com.yutou.qqbot.utlis.AppTools; import com.yutou.qqbot.utlis.HttpTools; import com.yutou.qqbot.utlis.Log; import net.mamoe.mirai.event.events.MessageEvent; @@ -29,7 +30,7 @@ public class Moyu extends Model { @Override public void onMessage(Long qq, MessageEvent event, boolean isGroup) { super.onMessage(qq, event, isGroup); - if(msg.equals(QQGroupCommands.QQ_MOYU)){ + if (msg.equals(QQGroupCommands.QQ_MOYU)) { send(qq); } } @@ -37,20 +38,29 @@ public class Moyu extends Model { @Override public void onTime(Long qq, String time) { super.onTime(qq, time); - if("10:00:00".equals(time)){ + if ("07:00:00".equals(time)) { + downloadImage(); + } + if ("10:00:00".equals(time)) { send(qq); } } - private void send(Long qq){ + private void downloadImage() { String ret = HttpTools.get("https://api.j4u.ink/proxy/remote/moyu.json"); - JSONObject json=JSONObject.parseObject(ret); - HttpTools.download(json.getJSONObject("data").getString("moyu_url"), qq+"_moyu.jpg", new DownloadInterface() { + JSONObject json = JSONObject.parseObject(ret); + HttpTools.download(json.getJSONObject("data").getString("moyu_url"), AppTools.getToDayTime() + "_moyu.jpg", new DownloadInterface() { @Override public void onDownload(File file) { super.onDownload(file); - QQBotManager.getInstance().sendMessage(file, qq, ""); } }); } + + private void send(Long qq) { + File file = new File(HttpTools.downloadPath + AppTools.getToDayTime() + "_moyu.jpg"); + if (file.exists()) { + QQBotManager.getInstance().sendMessage(file, qq, ""); + } + } }