更新机器人版本1.3.1 → 1.3.3
更新音乐收藏夹接口 工具类新增个打印异常的方法
This commit is contained in:
parent
acb1e90acb
commit
f575d0f287
2
pom.xml
2
pom.xml
@ -109,7 +109,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.mamoe</groupId>
|
<groupId>net.mamoe</groupId>
|
||||||
<artifactId>mirai-core-qqandroid</artifactId>
|
<artifactId>mirai-core-qqandroid</artifactId>
|
||||||
<version>1.3.1</version> <!-- 替换版本为最新版本 -->
|
<version>1.3.3</version> <!-- 替换版本为最新版本 -->
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
@ -9,7 +9,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class ToolsApplication {
|
public class ToolsApplication {
|
||||||
public static final String version="1.0.11";
|
public static final String version="1.0.12";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("当前版本号:"+version);
|
System.out.println("当前版本号:"+version);
|
||||||
|
@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 收藏夹相关
|
* 收藏夹相关
|
||||||
@ -51,6 +52,8 @@ public class MusicFavoritesController{
|
|||||||
json.put("data", JSONArray.toJSON(favoritesDirDao.selectByExample(new MusicFavoritesDirExample())));
|
json.put("data", JSONArray.toJSON(favoritesDirDao.selectByExample(new MusicFavoritesDirExample())));
|
||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
|
@RequestMapping("dir/rename.do")
|
||||||
|
@ResponseBody
|
||||||
public String renameFavoriteDir(String id,String title){
|
public String renameFavoriteDir(String id,String title){
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json=new JSONObject();
|
||||||
MusicFavoritesDir favoritesDir=favoritesDirDao.selectByPrimaryKey(Integer.parseInt(id));
|
MusicFavoritesDir favoritesDir=favoritesDirDao.selectByPrimaryKey(Integer.parseInt(id));
|
||||||
@ -65,4 +68,35 @@ public class MusicFavoritesController{
|
|||||||
}
|
}
|
||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
|
@RequestMapping("add.do")
|
||||||
|
@ResponseBody
|
||||||
|
public String addFavorite(int fid,String md5s){
|
||||||
|
JSONObject json=new JSONObject();
|
||||||
|
JSONArray array=JSONArray.parseArray(md5s);
|
||||||
|
if(array==null){
|
||||||
|
json.put("code",-1);
|
||||||
|
json.put("msg","参数异常");
|
||||||
|
return json.toJSONString();
|
||||||
|
}
|
||||||
|
for (Object o : array) {
|
||||||
|
String md5= (String) o;
|
||||||
|
MusicFavorites favorites=new MusicFavorites();
|
||||||
|
favorites.setMusisMd5(md5);
|
||||||
|
favorites.setFavoriteid(fid);
|
||||||
|
favorites.setSubTime(new Date());
|
||||||
|
favoritesDao.insert(favorites);
|
||||||
|
}
|
||||||
|
json.put("code",0);
|
||||||
|
json.put("msg","添加成功");
|
||||||
|
return json.toJSONString();
|
||||||
|
}
|
||||||
|
@RequestMapping("remove.do")
|
||||||
|
@ResponseBody
|
||||||
|
public String removeFavorite(int fid){
|
||||||
|
JSONObject json=new JSONObject();
|
||||||
|
int ret=favoritesDao.deleteByPrimaryKey(fid);
|
||||||
|
json.put("code",ret==0?-1:0);
|
||||||
|
json.put("msg",ret==0?"移除失败":"已从收藏夹中移除");
|
||||||
|
return json.toJSONString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,9 @@ public class MusicTools implements MusicToolsService {
|
|||||||
if (isScan) {
|
if (isScan) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(ConfigTools.load(ConfigTools.CONFIG,"musicScan").equals("false")){
|
||||||
|
return;
|
||||||
|
}
|
||||||
musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
|
musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
|
||||||
musicDataDao.truncate();
|
musicDataDao.truncate();
|
||||||
System.out.println("执行扫描:" + musicPath);
|
System.out.println("执行扫描:" + musicPath);
|
||||||
@ -129,10 +132,8 @@ public class MusicTools implements MusicToolsService {
|
|||||||
} else {
|
} else {
|
||||||
main = musicDataDao.selectByRegexp(path.replace(File.separator, replacement) + replacement + "([^" + replacement + "]+)$");
|
main = musicDataDao.selectByRegexp(path.replace(File.separator, replacement) + replacement + "([^" + replacement + "]+)$");
|
||||||
}
|
}
|
||||||
System.out.println(path + " " + isDir);
|
if (!path.equals(MusicController.defaultMusicPath) && !path.equals("root")) {
|
||||||
if (!path.equals(MusicController.defaultMusicPath) && !path.equals("root") && main.size() > 0) {
|
|
||||||
MusicData tmp = main.get(0);
|
MusicData tmp = main.get(0);
|
||||||
System.out.println(tmp);
|
|
||||||
MusicData t2 = new MusicData();
|
MusicData t2 = new MusicData();
|
||||||
t2.setTitle("返回");
|
t2.setTitle("返回");
|
||||||
t2.setFile(new File(tmp.getLastdir()).getAbsolutePath());
|
t2.setFile(new File(tmp.getLastdir()).getAbsolutePath());
|
||||||
@ -141,7 +142,6 @@ public class MusicTools implements MusicToolsService {
|
|||||||
}
|
}
|
||||||
getDirList(path, list);
|
getDirList(path, list);
|
||||||
list.addAll(main);
|
list.addAll(main);
|
||||||
System.out.println(list.size());
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,6 +404,7 @@ public class MusicTools implements MusicToolsService {
|
|||||||
data.setIsdir(file.isDirectory() ? 1 : 0);
|
data.setIsdir(file.isDirectory() ? 1 : 0);
|
||||||
data.setLastdir(file.getParentFile().getParent());
|
data.setLastdir(file.getParentFile().getParent());
|
||||||
data.setMd5(Tools.getFileMD5(file));
|
data.setMd5(Tools.getFileMD5(file));
|
||||||
|
QQBotManager.getInstance().sendMessage("添加音乐文件失败:\n"+data.toString()+"\n"+Tools.getExceptionString(e));
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,12 @@ import net.mamoe.mirai.event.Events;
|
|||||||
import net.mamoe.mirai.event.ListeningStatus;
|
import net.mamoe.mirai.event.ListeningStatus;
|
||||||
import net.mamoe.mirai.event.SimpleListenerHost;
|
import net.mamoe.mirai.event.SimpleListenerHost;
|
||||||
import net.mamoe.mirai.message.GroupMessageEvent;
|
import net.mamoe.mirai.message.GroupMessageEvent;
|
||||||
|
import net.mamoe.mirai.message.MessageEvent;
|
||||||
import net.mamoe.mirai.message.MessageReceipt;
|
import net.mamoe.mirai.message.MessageReceipt;
|
||||||
import net.mamoe.mirai.message.data.Image;
|
import net.mamoe.mirai.message.data.Image;
|
||||||
import net.mamoe.mirai.message.data.MessageChain;
|
import net.mamoe.mirai.message.data.MessageChain;
|
||||||
import net.mamoe.mirai.message.data.MessageUtils;
|
import net.mamoe.mirai.message.data.MessageUtils;
|
||||||
import net.mamoe.mirai.utils.BotConfiguration;
|
import net.mamoe.mirai.utils.BotConfiguration;
|
||||||
import net.mamoe.mirai.utils.MiraiLogger;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -70,16 +70,23 @@ public class QQBotManager {
|
|||||||
}
|
}
|
||||||
return botManager;
|
return botManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLogin() {
|
public boolean isLogin() {
|
||||||
return isLogin;
|
return isLogin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNotLoginQQ() {
|
private String getNotLoginQQ() {
|
||||||
return "没有登录QQ";
|
return "没有登录QQ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String sendMessage(String text) {
|
public String sendMessage(String text) {
|
||||||
if (bot != null) {
|
if (bot != null) {
|
||||||
|
try {
|
||||||
MessageReceipt<Contact> receipt = bot.getGroup(qqGroup).sendMessage(text);
|
MessageReceipt<Contact> receipt = bot.getGroup(qqGroup).sendMessage(text);
|
||||||
return receipt.toString();
|
return receipt.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return getNotLoginQQ();
|
return getNotLoginQQ();
|
||||||
}
|
}
|
||||||
@ -125,8 +132,15 @@ public class QQBotManager {
|
|||||||
RedisTools.Consumer.system("cmd", msg.replace("!cmd", ""));
|
RedisTools.Consumer.system("cmd", msg.replace("!cmd", ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}/*else{
|
||||||
|
sendMessage("群:"+event.getGroup().getId()+" 发来消息:\n"+event.getMessage().contentToString());
|
||||||
|
}*/
|
||||||
return ListeningStatus.LISTENING;
|
return ListeningStatus.LISTENING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onMessage(@NotNull MessageEvent event) throws Exception {
|
||||||
|
// sendMessage("个人:"+event.getSender().getNick()+" 发来消息:"+event.getMessage().contentToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -376,4 +376,16 @@ public class Tools {
|
|||||||
base=base.replace(" ","+");
|
base=base.replace(" ","+");
|
||||||
return new String(Base64.getDecoder().decode(base.replace("\r\n","").getBytes()));
|
return new String(Base64.getDecoder().decode(base.replace("\r\n","").getBytes()));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 异常输出
|
||||||
|
* @param e 异常
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getExceptionString(Exception e) {
|
||||||
|
StringWriter writer=new StringWriter();
|
||||||
|
PrintWriter printWriter=new PrintWriter(writer);
|
||||||
|
e.printStackTrace(printWriter);
|
||||||
|
printWriter.close();
|
||||||
|
return writer.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user