mirror of
https://github.com/Geniusay/ChopperBot.git
synced 2026-06-09 19:02:25 +08:00
小改动
This commit is contained in:
@@ -38,6 +38,34 @@ public abstract class ConfigFile<T> extends CommonPlugin {
|
||||
this.updateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public ConfigFile(String filePath, String fileName, T data,FileType fileType) {
|
||||
super(null, null, null, true);
|
||||
this.fileType = fileType;
|
||||
this.filePath = filePath;
|
||||
this.fileName = fileName;
|
||||
this.data = data;
|
||||
this.updateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public ConfigFile(String module, String pluginName, List<String> needPlugins, boolean isAutoStart,
|
||||
String filePath, String fileName, T data) {
|
||||
super(module, pluginName, needPlugins, isAutoStart);
|
||||
this.fileType = FileType.CONFIG;
|
||||
this.filePath = filePath;
|
||||
this.fileName = fileName;
|
||||
this.data = data;
|
||||
this.updateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public ConfigFile(String module, String pluginName, List<String> needPlugins, boolean isAutoStart,
|
||||
String filePath, String fileName, T data,FileType fileType) {
|
||||
super(module, pluginName, needPlugins, isAutoStart);
|
||||
this.fileType = fileType;
|
||||
this.filePath = filePath;
|
||||
this.fileName = fileName;
|
||||
this.data = data;
|
||||
this.updateTime = LocalDateTime.now();
|
||||
}
|
||||
/**
|
||||
* 用于最开始创建配置文件结构的打包
|
||||
* @return Map
|
||||
@@ -79,17 +107,6 @@ public abstract class ConfigFile<T> extends CommonPlugin {
|
||||
}
|
||||
|
||||
|
||||
public ConfigFile(String module, String pluginName, List<String> needPlugins, boolean isAutoStart,
|
||||
String filePath, String fileName, T data) {
|
||||
super(module, pluginName, needPlugins, isAutoStart);
|
||||
this.fileType = FileType.CONFIG;
|
||||
this.filePath = filePath;
|
||||
this.fileName = fileName;
|
||||
this.data = data;
|
||||
this.updateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
|
||||
public String getFilePath() {
|
||||
return this.filePath;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ import org.example.log.LoggerType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.example.constpool.ConstPool.CREEPER;
|
||||
import static org.example.constpool.ConstPool.FILE;
|
||||
import static org.example.constpool.ConstPool.*;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
@@ -15,7 +14,7 @@ import static org.example.constpool.ConstPool.FILE;
|
||||
**/
|
||||
public class CreeperModuleInitMachine extends ModuleInitMachine {
|
||||
public CreeperModuleInitMachine() {
|
||||
super(List.of(FILE), ChopperLogFactory.getLogger(LoggerType.Creeper), CREEPER);
|
||||
super(List.of(FILE,LIVE_RECORD), ChopperLogFactory.getLogger(LoggerType.Creeper), CREEPER);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class HotModuleGuard extends CommonPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init() {
|
||||
public boolean init(){
|
||||
try {
|
||||
FileCache HotModuleFileCache = FileCacheManagerInstance.getInstance().getFileCache(HotModuleConfig.getFullFilePath());
|
||||
|
||||
@@ -74,7 +74,7 @@ public class HotModuleGuard extends CommonPlugin {
|
||||
runningGuards = new ConcurrentHashMap<>();
|
||||
start();
|
||||
}catch (Exception e){
|
||||
return false;
|
||||
throw e;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,6 @@ public class HeatRecommendation extends GuardPlugin {
|
||||
for (Live live : needRecommend(lives, followDog.getBanLiver(), followDog.getTop())) {
|
||||
String tempPlatform = live.getPlatform();
|
||||
this.info(String.format("推荐请求:平台 %s,直播间 %s,主播 %s",tempPlatform,live.getLiveId(),live.getLiver()));
|
||||
new DouyuLiveLoadBarrageConfig(live.getLiver(),String.valueOf(live.getLiveId()));
|
||||
LoadLiveConfig loadLiveConfig = LiveLoadConfigFactory.buildLiveConfig(
|
||||
tempPlatform, live.getLiveId(), live.getLiver(),
|
||||
true, true);
|
||||
|
||||
@@ -28,4 +28,23 @@ public class HotConfigInitMachine extends ConfigInitMachine {
|
||||
public HotConfigInitMachine(List<String> needPlugins, boolean isAutoStart, String moduleName, String name, Class<? extends CommonPlugin> clazz) {
|
||||
super(needPlugins, isAutoStart, moduleName, name, clazz);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
int i = 0;
|
||||
while (true){
|
||||
clearConsole(2);
|
||||
System.out.printf("A times:%s\n", i);
|
||||
System.out.printf("B times:%s\n", i);
|
||||
Thread.sleep(1000);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void clearConsole(int lines) {
|
||||
for (int i = 0; i < lines; i++) {
|
||||
System.out.print("\033[2K"); // 清除当前行
|
||||
System.out.print("\033[1A"); // 上移一行
|
||||
}
|
||||
System.out.print("\033[2K"); // 清除最后一行
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,13 @@ import org.example.core.creeper.loadconfig.DouyuLiveOnlineConfig;
|
||||
import org.example.core.creeper.loadconfig.LoadLiveConfig;
|
||||
import org.example.pool.LiveModuleConstPool;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
@@ -52,5 +59,4 @@ public class LiveLoadConfigFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.example.init;
|
||||
|
||||
import org.example.config.LiveModuleConfigFile;
|
||||
import org.example.constpool.ConstPool;
|
||||
import org.example.constpool.ModuleName;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.plugin.CommonPlugin;
|
||||
import org.example.plugin.annotation.Plugin;
|
||||
import org.example.pool.LiveModuleConstPool;
|
||||
import org.example.util.FileUtil;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
* @date 2023/09/01 01:13
|
||||
**/
|
||||
@Plugin(moduleName = ModuleName.LIVE,
|
||||
pluginName = PluginName.LIVE_CONFIG_PLUGIN,
|
||||
pluginName_CN = "直播模块配置文件",
|
||||
needPlugin = {PluginName.FILE_CACHE_PLUGIN},
|
||||
pluginClass= LiveModuleConfigFile.class )
|
||||
public class LiveConfigInitMachine extends ConfigInitMachine{
|
||||
|
||||
public LiveConfigInitMachine(List<String> needPlugins, boolean isAutoStart, String moduleName, String name, Class<? extends CommonPlugin> clazz) {
|
||||
super(needPlugins, isAutoStart, moduleName, name, clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init() {
|
||||
String fullPath = LiveModuleConstPool.LIVE_MODULE_CONFIG_ROOT;
|
||||
String online = "online";
|
||||
String record = "record";
|
||||
try {
|
||||
Path onlinePath = Path.of(fullPath,online);
|
||||
Path recordPath = Path.of(fullPath,record);
|
||||
if(!FileUtil.isFileExist(onlinePath.toString())){
|
||||
Files.createDirectory(onlinePath);
|
||||
}
|
||||
if(!FileUtil.isFileExist(recordPath.toString())){
|
||||
Files.createDirectory(recordPath);
|
||||
}
|
||||
for (ConstPool.PLATFORM value : ConstPool.PLATFORM.values()) {
|
||||
String name = value.getName();
|
||||
Path onlinePlatformPath = Path.of(onlinePath.toString(), name);
|
||||
Path recordPlatformPath = Path.of(recordPath.toString(), name);
|
||||
if(!FileUtil.isFileExist(onlinePlatformPath.toString())){
|
||||
logger.info("[{}}] 构建文件夹 {}",pluginName,onlinePlatformPath);
|
||||
Files.createDirectory(onlinePlatformPath);
|
||||
}
|
||||
if(!FileUtil.isFileExist(recordPlatformPath.toString())){
|
||||
logger.info("[{}}] 构建文件夹 {}",pluginName,recordPlatformPath);
|
||||
Files.createDirectory(recordPlatformPath);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return fail(e.getMessage());
|
||||
}
|
||||
return super.init();
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class LiveModuleInitMachine extends ModuleInitMachine {
|
||||
|
||||
public LiveModuleInitMachine() {
|
||||
super(
|
||||
List.of(ConstPool.FILE,ConstPool.CREEPER),
|
||||
List.of(ConstPool.FILE),
|
||||
ChopperLogFactory.getLogger(LoggerType.LiveRecord),
|
||||
ModuleName.LIVE
|
||||
);
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
"TaskCenter":true,
|
||||
"CreeperConfig":true,
|
||||
"LiveDownLoadManager":true,
|
||||
"LiveConfig":true,
|
||||
"HotRecommendation":true
|
||||
}
|
||||
},
|
||||
"updateTime":"2023-09-01 00:47:33"
|
||||
"updateTime":"2023-09-01 01:31:43"
|
||||
}
|
||||
Reference in New Issue
Block a user