From 4cbcba6b6e82a361e135895ab384bb9c884f8940 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Fri, 8 Apr 2022 16:42:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=91=B8=E9=B1=BC=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=20=E6=B5=8B=E8=AF=95=E5=A4=A7=E5=A4=B4=E8=8F=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yutou/qqbot/QQBotManager.java | 2 + .../qqbot/models/Animal/TurnipProphet.java | 5 +- .../com/yutou/qqbot/models/Commands/Moyu.java | 55 +++++++++++++++++++ .../java/com/yutou/qqbot/models/Model.java | 1 + 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/yutou/qqbot/models/Commands/Moyu.java diff --git a/src/main/java/com/yutou/qqbot/QQBotManager.java b/src/main/java/com/yutou/qqbot/QQBotManager.java index e0aeba9..3a8c9dd 100644 --- a/src/main/java/com/yutou/qqbot/QQBotManager.java +++ b/src/main/java/com/yutou/qqbot/QQBotManager.java @@ -5,6 +5,7 @@ import com.yutou.qqbot.models.Animal.TurnipProphet; import com.yutou.qqbot.models.Commands.BaiduDown; import com.yutou.qqbot.models.Commands.Bangumi; import com.yutou.qqbot.models.Commands.BTDownload; +import com.yutou.qqbot.models.Commands.Moyu; import com.yutou.qqbot.models.Commands.System.*; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.models.WebSign.BiliBiliMangeSign; @@ -51,6 +52,7 @@ public class QQBotManager { Model.classList.add(GetSeTu.class); Model.classList.add(BTDownload.class); Model.classList.add(BiliBiliMangeSign.class); + Model.classList.add(Moyu.class); } private static QQBotManager botManager = null; private Bot bot; diff --git a/src/main/java/com/yutou/qqbot/models/Animal/TurnipProphet.java b/src/main/java/com/yutou/qqbot/models/Animal/TurnipProphet.java index a3534c2..68eda54 100644 --- a/src/main/java/com/yutou/qqbot/models/Animal/TurnipProphet.java +++ b/src/main/java/com/yutou/qqbot/models/Animal/TurnipProphet.java @@ -64,10 +64,12 @@ public class TurnipProphet extends Model { @Override public void onMessage(Long qq, MessageEvent event, boolean isGroup) { super.onMessage(qq, event, isGroup); + System.out.println("测试大头菜"); user = qq; sendQQ = qq; if (isGroup) { if (!event.getMessage().serializeToMiraiCode().contains("[mirai:at:2476945931]")) { + System.out.println("没有@?"); return; } user = event.getSource().getFromId(); @@ -75,7 +77,7 @@ public class TurnipProphet extends Model { int money = -1; try { if (isGroup) { - msg = msg.replace("@2476945931", ""); + msg = msg.replace("@2476945931", "").trim(); } money = Integer.parseInt(msg.trim()); } catch (Exception e) { @@ -88,6 +90,7 @@ public class TurnipProphet extends Model { } private void showData() { + System.out.println("发送数据"); String redisKey = user + "_turnip"; String data = RedisTools.get(redisKey); if (StringUtils.isEmpty(data)) { diff --git a/src/main/java/com/yutou/qqbot/models/Commands/Moyu.java b/src/main/java/com/yutou/qqbot/models/Commands/Moyu.java new file mode 100644 index 0000000..146bbcd --- /dev/null +++ b/src/main/java/com/yutou/qqbot/models/Commands/Moyu.java @@ -0,0 +1,55 @@ +package com.yutou.qqbot.models.Commands; + +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.HttpTools; +import net.mamoe.mirai.event.events.MessageEvent; + +import java.io.File; + +public class Moyu extends Model { + @Override + public boolean isUserPublic() { + return true; + } + + @Override + public String[] getUsePowers() { + return new String[0]; + } + + @Override + public String getModelName() { + return "摸鱼提醒"; + } + + @Override + public void onMessage(Long qq, MessageEvent event, boolean isGroup) { + super.onMessage(qq, event, isGroup); + if(msg.equals(QQGroupCommands.QQ_MOYU)){ + send(qq); + } + } + + @Override + public void onTime(Long qq, String time) { + super.onTime(qq, time); + if("08:00:00".equals(time)){ + send(qq); + } + } + + private void send(Long qq){ + 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"), "moyu.jpg", new DownloadInterface() { + @Override + public void onDownload(File file) { + super.onDownload(file); + QQBotManager.getInstance().sendMessage(file,qq,""); + } + }); + } +} diff --git a/src/main/java/com/yutou/qqbot/models/Model.java b/src/main/java/com/yutou/qqbot/models/Model.java index 41ca5d2..381af07 100644 --- a/src/main/java/com/yutou/qqbot/models/Model.java +++ b/src/main/java/com/yutou/qqbot/models/Model.java @@ -33,6 +33,7 @@ public abstract class Model implements ModelInterface { public final static String QQ_TOOLS_IDEA_URL = "!idea_url"; public final static String QQ_BANGUMI_INFO = "!保存动画信息>"; + public final static String QQ_MOYU = "!摸鱼"; }