This commit is contained in:
Yutousama 2022-04-11 12:49:15 +08:00
parent 5c7b864259
commit 4e3810b256
2 changed files with 18 additions and 10 deletions

View File

@ -49,6 +49,7 @@ public class BiliVideoController {
}
if (ServiceTools.getInstance().auth(request, user.getUser(), "/bili/video/get/")) {
File file = new File(ConfigTools.load(ConfigTools.CONFIG,"liveSavePath",String.class)+File.separator+"live");
Log.i(file.getAbsolutePath());
if (!file.exists() || Objects.requireNonNull(file.listFiles()).length == 0) {
json.put("code", 0);
json.put("msg", "文件夹为空");
@ -109,6 +110,7 @@ public class BiliVideoController {
if (!file.exists()) {
file = new File(ConfigTools.load(ConfigTools.CONFIG,"liveSavePath",String.class)+File.separator+"live" + File.separator + time + File.separator + fileName);
}
Log.i(file.getAbsolutePath());
com.yutou.bilibili.Tools.Log.i(file.getAbsolutePath());
return AppTools.getFile(file);
}

View File

@ -9,14 +9,20 @@ import com.yutou.bilibili.BilibiliApplication;
import com.yutou.bilibili.Tools.*;
import com.yutou.bilibili.interfaces.DownloadInterface;
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo;
import kotlin.coroutines.CoroutineContext;
import net.mamoe.mirai.Bot;
import net.mamoe.mirai.BotFactory;
import net.mamoe.mirai.event.EventHandler;
import net.mamoe.mirai.event.GlobalEventChannel;
import net.mamoe.mirai.event.ListeningStatus;
import net.mamoe.mirai.event.SimpleListenerHost;
import net.mamoe.mirai.event.events.GroupMessageEvent;
import net.mamoe.mirai.event.events.MessageEvent;
import net.mamoe.mirai.message.data.Image;
import net.mamoe.mirai.message.data.MessageChainBuilder;
import net.mamoe.mirai.utils.BotConfiguration;
import net.mamoe.mirai.utils.ExternalResource;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@ -99,7 +105,7 @@ public class QQBotManager implements ApplicationContextAware {
}
});
//Events.registerEvents(bot, new MessageListener());
GlobalEventChannel.INSTANCE.subscribeAlways(GroupMessageEvent.class, new MessageListener());
GlobalEventChannel.INSTANCE.registerListenerHost(new MessageListener());
Log.i("准备登陆");
bot.login();
Log.i("登陆成功");
@ -231,18 +237,17 @@ public class QQBotManager implements ApplicationContextAware {
getInstance();
}
private static class MessageListener implements Consumer<GroupMessageEvent> {
private static class MessageListener extends SimpleListenerHost {
@Override
public void accept(GroupMessageEvent event) {
String msg = event.getMessage().contentToString();
if (qqGroup == event.getGroup().getId()) {
myGroup(msg);
}
public void handleException(@NotNull CoroutineContext context, @NotNull Throwable exception) {
// super.handleException(context, exception);
exception.printStackTrace();
}
private void myGroup(String message) {
@EventHandler
public ListeningStatus onMessage(MessageEvent event) {
String message=event.getMessage().contentToString();
String msg = message.replace("", "!").toLowerCase();
msg=msg.trim();
StringBuilder builder = new StringBuilder();
@ -368,6 +373,7 @@ public class QQBotManager implements ApplicationContextAware {
Log.i("未知指令:"+msg);
}
}
return ListeningStatus.LISTENING; // 表示继续监听事件
}
public void sendGiftData(int roomId, Date startTime, Date endTime) {