调整QQ对外接口

This commit is contained in:
Yutou 2024-06-09 11:37:39 +08:00
parent 120392be17
commit ebe96127e5
3 changed files with 20 additions and 14 deletions

View File

@ -2,6 +2,7 @@ package com.yutou.qqbot.Controllers;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.napcat.QQDatabase;
import com.yutou.napcat.handle.At;
import com.yutou.napcat.handle.BaseHandle;
import com.yutou.napcat.handle.Image;
import com.yutou.napcat.handle.Text;
@ -22,6 +23,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Controller
public class AppController {
@ -71,10 +74,14 @@ public class AppController {
if (json.getString("message").isEmpty()) {
return "not message";
}
List<BaseHandle<?>> list=new ArrayList<>();
list.add(new Text(json.getString("message")));
if(json.getString("image")!=null&&!json.getString("image").isEmpty()){
list.add(new Image(json.getString("image")));
}
SendMessageResponse sent = QQBotManager.getInstance().sendMessage(QQDatabase.checkFriend(json.getLong("qq")),
json.getLong("qq"),
new Text(json.getString("message")),
new Image(json.getString("image"))
list
);
return sent == null ? "0" : sent.getId() + "";
}

View File

@ -10,7 +10,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class QQBotApplication {
public static final String version = "QQBot v.1.7.6";
public static final String version = "QQBot v.1.7.6.2";
public static void main(String[] args) {
System.out.println("version = " + version);

View File

@ -1,11 +1,16 @@
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 {
@ -33,18 +38,12 @@ public class BTDownload extends Model {
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);
String exec = String.format("qbittorrent-nox --save-path=%sdownload_tmp/%s \"%s\" "
, DownloadHomePath
, AppTools.getToDayTime()
, msg
);
AppTools.exec(exec, new ObjectInterface() {
@Override
public void out(String data) {
super.out(data);
}
}, true, false);
}
}
}