From 191a1fc6edd58ef24eaa25f36c383c83f202360b Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Thu, 9 Dec 2021 13:22:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=90=8C=E6=AD=A5=E7=99=BE?= =?UTF-8?q?=E5=BA=A6=E4=BA=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yutou/qqbot/QQBotManager.java | 2 + .../qqbot/models/Commands/BaiduDown.java | 40 +++++++++++++++++++ .../java/com/yutou/qqbot/models/Model.java | 1 + 3 files changed, 43 insertions(+) create mode 100644 src/main/java/com/yutou/qqbot/models/Commands/BaiduDown.java diff --git a/src/main/java/com/yutou/qqbot/QQBotManager.java b/src/main/java/com/yutou/qqbot/QQBotManager.java index d2927d8..196b3be 100644 --- a/src/main/java/com/yutou/qqbot/QQBotManager.java +++ b/src/main/java/com/yutou/qqbot/QQBotManager.java @@ -2,6 +2,7 @@ package com.yutou.qqbot; import com.yutou.qqbot.Listeners.QQMessageListener; 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.System.*; import com.yutou.qqbot.models.Commands.Tsdm; @@ -40,6 +41,7 @@ public class QQBotManager { Model.classList.add(TurnipProphet.class); Model.classList.add(Tsdm.class); + Model.classList.add(BaiduDown.class); } private static QQBotManager botManager = null; private Bot bot; diff --git a/src/main/java/com/yutou/qqbot/models/Commands/BaiduDown.java b/src/main/java/com/yutou/qqbot/models/Commands/BaiduDown.java new file mode 100644 index 0000000..3b0b710 --- /dev/null +++ b/src/main/java/com/yutou/qqbot/models/Commands/BaiduDown.java @@ -0,0 +1,40 @@ +package com.yutou.qqbot.models.Commands; + +import com.yutou.qqbot.QQBotManager; +import com.yutou.qqbot.interfaces.ObjectInterface; +import com.yutou.qqbot.models.Model; +import com.yutou.qqbot.utlis.AppTools; +import com.yutou.qqbot.utlis.Log; +import net.mamoe.mirai.event.events.MessageEvent; + +import java.io.File; + +public class BaiduDown extends Model { + @Override + public boolean isUserPublic() { + return false; + } + + @Override + public String[] getUsePowers() { + return new String[]{ + QQFromCommands.BAIDU_DOWN + }; + } + + @Override + public void onMessage(Long qq, MessageEvent event, boolean isGroup) { + super.onMessage(qq, event, isGroup); + if(msg.startsWith(QQFromCommands.BAIDU_DOWN)){ + QQBotManager.getInstance().sendMessage(qq,"开始同步百度云"); + AppTools.exec("cd "+new File("baidupan").getAbsolutePath()+" && bypy downdir -v", new ObjectInterface() { + @Override + public void out(String data) { + super.out(data); + Log.i(data); + QQBotManager.getInstance().sendMessage(qq,"任务完成"); + } + },true,true); + } + } +} diff --git a/src/main/java/com/yutou/qqbot/models/Model.java b/src/main/java/com/yutou/qqbot/models/Model.java index 5370033..85f81f4 100644 --- a/src/main/java/com/yutou/qqbot/models/Model.java +++ b/src/main/java/com/yutou/qqbot/models/Model.java @@ -38,6 +38,7 @@ public abstract class Model implements ModelInterface { public static final String TURNIP_PROPHET = "大头菜"; public static final String TSDM_PAY = "!tsdm"; public static final String TSDM_SIGN = "!tsdm签到"; + public static final String BAIDU_DOWN = "!bd"; }