From f825302b5fe67070c81e55d7cef2bcbd4ed06da8 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Thu, 17 Mar 2022 09:43:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=B4=E6=97=B6=E7=A3=81?= =?UTF-8?q?=E9=93=BE=E4=B8=8B=E8=BD=BD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yutou/qqbot/QQBotApplication.java | 2 +- .../java/com/yutou/qqbot/QQBotManager.java | 4 +- .../qqbot/models/Commands/BTDownload.java | 42 +++++++++++++++++++ .../yutou/qqbot/models/Commands/OpenDoor.java | 29 ------------- .../java/com/yutou/qqbot/models/Model.java | 2 +- 5 files changed, 46 insertions(+), 33 deletions(-) create mode 100644 src/main/java/com/yutou/qqbot/models/Commands/BTDownload.java delete mode 100644 src/main/java/com/yutou/qqbot/models/Commands/OpenDoor.java diff --git a/src/main/java/com/yutou/qqbot/QQBotApplication.java b/src/main/java/com/yutou/qqbot/QQBotApplication.java index bb796dc..b86c2e4 100644 --- a/src/main/java/com/yutou/qqbot/QQBotApplication.java +++ b/src/main/java/com/yutou/qqbot/QQBotApplication.java @@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class QQBotApplication { - public static final String version="QQBot v.1.2.9"; + public static final String version="QQBot v.1.2.10"; public static void main(String[] args) { System.out.println("version = " + version); SpringApplication.run(QQBotApplication.class, args); diff --git a/src/main/java/com/yutou/qqbot/QQBotManager.java b/src/main/java/com/yutou/qqbot/QQBotManager.java index 31b1b60..2e87c7f 100644 --- a/src/main/java/com/yutou/qqbot/QQBotManager.java +++ b/src/main/java/com/yutou/qqbot/QQBotManager.java @@ -4,7 +4,7 @@ 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.OpenDoor; +import com.yutou.qqbot.models.Commands.BTDownload; import com.yutou.qqbot.models.Commands.System.*; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.models.WebSign.Tsdm; @@ -48,7 +48,7 @@ public class QQBotManager { Model.classList.add(BaiduDown.class); Model.classList.add(MiRouter.class); Model.classList.add(GetSeTu.class); - Model.classList.add(OpenDoor.class); + Model.classList.add(BTDownload.class); } private static QQBotManager botManager = null; private Bot bot; diff --git a/src/main/java/com/yutou/qqbot/models/Commands/BTDownload.java b/src/main/java/com/yutou/qqbot/models/Commands/BTDownload.java new file mode 100644 index 0000000..6b44242 --- /dev/null +++ b/src/main/java/com/yutou/qqbot/models/Commands/BTDownload.java @@ -0,0 +1,42 @@ +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 net.mamoe.mirai.event.events.MessageEvent; + +public class BTDownload extends Model { + private static final String DownloadHomePath="/media/yutou/disk_lvm/public/download/"; + @Override + public boolean isUserPublic() { + return false; + } + + @Override + public String[] getUsePowers() { + return new String[]{ + QQFromCommands.BT_DOWNLOAD + }; + } + + @Override + public void onMessage(Long qq, MessageEvent event, boolean isGroup) { + super.onMessage(qq, event, isGroup); + if(msg.startsWith("magnet:?xt=")){ + String builder = "已添加下载磁链" ; + QQBotManager.getInstance().sendMessage(qq, builder); + String exec = String.format("transmission-remote -n yutou:34864394 -w %sdownload_tmp/%s -a \"%s\" " + ,DownloadHomePath + , AppTools.getToDayTime() + , msg + ); + AppTools.exec(exec, new ObjectInterface() { + @Override + public void out(String data) { + super.out(data); + } + },true,false); + } + } +} diff --git a/src/main/java/com/yutou/qqbot/models/Commands/OpenDoor.java b/src/main/java/com/yutou/qqbot/models/Commands/OpenDoor.java deleted file mode 100644 index 6c2dae6..0000000 --- a/src/main/java/com/yutou/qqbot/models/Commands/OpenDoor.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.yutou.qqbot.models.Commands; - -import com.yutou.qqbot.QQBotManager; -import com.yutou.qqbot.models.Model; -import net.mamoe.mirai.event.events.MessageEvent; - -public class OpenDoor extends Model { - @Override - public boolean isUserPublic() { - return false; - } - - @Override - public String[] getUsePowers() { - return new String[]{ - QQFromCommands.DOOR_OPEN - }; - } - - @Override - public void onMessage(Long qq, MessageEvent event, boolean isGroup) { - super.onMessage(qq, event, isGroup); - if(msg.equals(QQFromCommands.DOOR_OPEN)){ - String builder = "点击该链接开门:" + "\n" + - "http://192.168.31.88:802/openDoor.html"; - QQBotManager.getInstance().sendMessage(qq, builder); - } - } -} diff --git a/src/main/java/com/yutou/qqbot/models/Model.java b/src/main/java/com/yutou/qqbot/models/Model.java index 4d50cfc..576b825 100644 --- a/src/main/java/com/yutou/qqbot/models/Model.java +++ b/src/main/java/com/yutou/qqbot/models/Model.java @@ -43,7 +43,7 @@ public abstract class Model implements ModelInterface { public static final String BAIDU_DOWN = "!bd"; public static final String ROUTER_ADD = "!添加设备"; public static final String ROUTER_DEL = "!删除设备"; - public static final String DOOR_OPEN = "开门"; + public static final String BT_DOWNLOAD = "下载bt"; }