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 = "!摸鱼"; }