50 lines
1.6 KiB
Java
50 lines
1.6 KiB
Java
package com.yutou.qqbot.models.Commands;
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.yutou.qqbot.Annotations.UseModel;
|
|
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.napcat.event.MessageEvent;
|
|
import com.yutou.qqbot.utlis.ConfigTools;
|
|
import com.yutou.qqbot.utlis.HttpTools;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
@UseModel
|
|
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 String getModelName() {
|
|
return "添加BT下载";
|
|
}
|
|
|
|
@Override
|
|
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
|
super.onMessage(qq, event, isGroup);
|
|
if (msg.startsWith("magnet:?xt=")) {
|
|
String builder = "已添加下载磁链";
|
|
JSONObject json = new JSONObject();
|
|
json.put("url", msg.trim());
|
|
json.put("title", "qqbot/" + System.currentTimeMillis() + ".torrent");
|
|
String post = HttpTools.post(ConfigTools.getServerUrl()+"qq/bt/download.do", json.toString().getBytes(StandardCharsets.UTF_8));
|
|
builder += "\n" + post;
|
|
QQBotManager.getInstance().sendMessage(event.isUser(), qq, builder);
|
|
}
|
|
}
|
|
}
|