完成基本功能转移
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
package com.yutou.qqbot.Controllers;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.napcat.QQDatabase;
|
||||
import com.yutou.napcat.handle.BaseHandle;
|
||||
import com.yutou.napcat.handle.Image;
|
||||
import com.yutou.napcat.handle.Text;
|
||||
import com.yutou.napcat.model.SendMessageResponse;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.utlis.AppTools;
|
||||
import com.yutou.qqbot.utlis.HttpTools;
|
||||
import com.yutou.qqbot.utlis.RedisTools;
|
||||
import com.yutou.qqbot.utlis.StringUtils;
|
||||
import net.mamoe.mirai.message.MessageReceipt;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -64,44 +68,46 @@ public class AppController {
|
||||
@RequestMapping("/qq/send.do")
|
||||
public String sendQQ(@RequestBody JSONObject json) {
|
||||
File image = null;
|
||||
MessageReceipt<?> ret;
|
||||
if(json.getString("message").isEmpty()){
|
||||
if (json.getString("message").isEmpty()) {
|
||||
return "not message";
|
||||
}
|
||||
if (json.containsKey("image")) {
|
||||
image = HttpTools.syncDownload(json.getString("image"), System.currentTimeMillis() + ".png",true);
|
||||
}
|
||||
ret = QQBotManager.getInstance().sendMessage(image, json.getLong("qq"), json.getString("message"));
|
||||
return ret==null?"message send fail":"message send success";
|
||||
SendMessageResponse sent = QQBotManager.getInstance().sendMessage(QQDatabase.checkFriend(json.getLong("qq")),
|
||||
json.getLong("qq"),
|
||||
new Text(json.getString("message")),
|
||||
new Image(json.getString("image"))
|
||||
);
|
||||
return sent == null ? "0" : sent.getId() + "";
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/qq/file.do")
|
||||
public String sendFile(@RequestParam("image") MultipartFile file) throws Exception {
|
||||
String path=AppTools.createFile("tmp",file,System.currentTimeMillis()+".png");
|
||||
if(StringUtils.isEmpty(path)){
|
||||
String path = AppTools.createFile("tmp", file, System.currentTimeMillis() + ".png");
|
||||
if (StringUtils.isEmpty(path)) {
|
||||
return "not file";
|
||||
}
|
||||
File _file=new File(path);
|
||||
QQBotManager.getInstance().sendMessage(_file,583819556L,"time = "+AppTools.getToDayNowTimeToString());
|
||||
File _file = new File(path);
|
||||
QQBotManager.getInstance().sendMessage(_file, 583819556L, "time = " + AppTools.getToDayNowTimeToString());
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@RequestMapping("/test.do")
|
||||
@ResponseBody
|
||||
public String test(HttpServletResponse response){
|
||||
public String test(HttpServletResponse response) {
|
||||
System.out.println("NAS自动关机");
|
||||
/* try {
|
||||
response.sendRedirect("http://192.168.31.88:9999/live/index.m3u8");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
// return HttpTools.http_get("http://192.168.31.88:9999/live/index.m3u8",null);
|
||||
// return HttpTools.http_get("http://192.168.31.88:9999/live/index.m3u8",null);
|
||||
return "1";
|
||||
}
|
||||
|
||||
@RequestMapping("*.ts")
|
||||
public void test2(HttpServletResponse response, HttpServletRequest request){
|
||||
public void test2(HttpServletResponse response, HttpServletRequest request) {
|
||||
try {
|
||||
response.sendRedirect("http://192.168.31.88:9999/live"+request.getRequestURI());
|
||||
response.sendRedirect("http://192.168.31.88:9999/live" + request.getRequestURI());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user