diff --git a/chopperbot-barrage/src/main/java/org/example/api/BarrageScoreCurvePluginApi.java b/chopperbot-barrage/src/main/java/org/example/api/BarrageScoreCurvePluginApi.java new file mode 100644 index 0000000..e3a7fe3 --- /dev/null +++ b/chopperbot-barrage/src/main/java/org/example/api/BarrageScoreCurvePluginApi.java @@ -0,0 +1,76 @@ +package org.example.api; + +import org.example.bean.BarrageCurveVO; +import org.example.bean.LiverKeyword; +import org.example.config.BarrageModuleConfig; +import org.example.core.bgevnet.BarrageEvent; +import org.example.core.bgevnet.bgscore.BarragePoint; +import org.example.core.bgevnet.bgscore.BarrageScoreCurvePlugin; +import org.example.service.LiverKeywordService; +import org.example.util.ConfigFileUtil; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author Genius + * @date 2023/10/13 16:45 + **/ +@Component +public class BarrageScoreCurvePluginApi { + + @Resource + private BarrageScoreCurvePlugin barrageScoreCurvePlugin; + + @Resource + private LiverKeywordService keywordService; + + public List curveVOList(){ + List curveVOList = new ArrayList<>(); + barrageScoreCurvePlugin.getBarragePointMap().forEach( + (k,v)->{ + curveVOList.add(new BarrageCurveVO(k,v)); + } + ); + return curveVOList; + } + + public BarrageCurveVO generateCurve(String filePath,String liver){ + BarrageEvent event = new BarrageEvent(); + event.setFileName(filePath); + event.setLiver(liver); + List points = barrageScoreCurvePlugin.generateCurve(event); + return new BarrageCurveVO(filePath,points); + } + + public List getKeyWords(String anchor){ + return barrageScoreCurvePlugin.getKetWords(anchor); + } + + public List getKeyWords(){ + return keywordService.getGlobalKeyWords(); + } + + public boolean updateKeyWord(LiverKeyword keyword){ + return keywordService.updateKeyWord(keyword); + } + + public boolean addKeyWord(LiverKeyword keyword){ + return keywordService.addKeyWord(keyword); + } + + public boolean deleteKeyWord(String anchor,String keyword){ + return keywordService.deleteKeyWord(anchor,keyword); + } + + public void changeSetting(Map settings){ + ConfigFileUtil.changeSetting(settings,BarrageModuleConfig.getFullFilePath(),"barrageScoreCurve"); + } + + public Object getSetting(){ + return ConfigFileUtil.getSetting(BarrageModuleConfig.getFullFilePath(),"barrageScoreCurve"); + } +} diff --git a/chopperbot-barrage/src/main/java/org/example/bean/BarrageCurveVO.java b/chopperbot-barrage/src/main/java/org/example/bean/BarrageCurveVO.java new file mode 100644 index 0000000..4dd14a6 --- /dev/null +++ b/chopperbot-barrage/src/main/java/org/example/bean/BarrageCurveVO.java @@ -0,0 +1,21 @@ +package org.example.bean; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.example.core.bgevnet.bgscore.BarragePoint; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author Genius + * @date 2023/10/13 16:46 + **/ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class BarrageCurveVO { + private String filePath; + private List points; +} diff --git a/chopperbot-barrage/src/main/java/org/example/core/bgevnet/BarrageEvent.java b/chopperbot-barrage/src/main/java/org/example/core/bgevnet/BarrageEvent.java index 6653750..f5b2bf9 100644 --- a/chopperbot-barrage/src/main/java/org/example/core/bgevnet/BarrageEvent.java +++ b/chopperbot-barrage/src/main/java/org/example/core/bgevnet/BarrageEvent.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import org.example.bean.Barrage; import org.example.constpool.BarrageModuleConstPool; import org.example.constpool.FileNameBuilder; @@ -24,6 +25,7 @@ import java.util.stream.Collectors; * @date 2023/09/13 18:21 **/ @Data +@NoArgsConstructor public class BarrageEvent { private String platform; @@ -63,6 +65,9 @@ public class BarrageEvent { } public String getBarrageFilePath(){ + if(platform==null||action==null){ + return fileName; + } return Paths.get(BarrageSaveFile.fileRoot(action,platform), fileName).toString(); } diff --git a/chopperbot-barrage/src/main/java/org/example/core/bgevnet/bgscore/BarrageScoreCurvePlugin.java b/chopperbot-barrage/src/main/java/org/example/core/bgevnet/bgscore/BarrageScoreCurvePlugin.java index 2d655c2..43567bc 100644 --- a/chopperbot-barrage/src/main/java/org/example/core/bgevnet/bgscore/BarrageScoreCurvePlugin.java +++ b/chopperbot-barrage/src/main/java/org/example/core/bgevnet/bgscore/BarrageScoreCurvePlugin.java @@ -14,6 +14,7 @@ import org.example.core.bgevnet.bgscore.split.SplitStrategyFactory; import org.example.plugin.SpringBootPlugin; import org.example.service.LiverKeywordService; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; import javax.annotation.Resource; import java.util.*; @@ -55,12 +56,15 @@ public class BarrageScoreCurvePlugin extends SpringBootPlugin { String liver = event.getLiver(); String path = event.getBarrageFilePath(); long duration = Long.parseLong(fileCache.get("barrageScoreCurve", "duration").toString()); - List liverKeyWords = service.getLiverKeyWords(liver); + + List liverKeyWords = getKetWords(liver); + Map liverKeywordMap = generateKeyMap(liverKeyWords); String splitType = (String) fileCache.get("barrageScoreCurve", "splitStrategy"); String scoreType = (String) fileCache.get("barrageScoreCurve", "scoreStrategy"); AbstractScoreStrategy scoreStrategy = ScoreStrategyFactory.build(scoreType, liverKeywordMap); + if(scoreType!=null){ AbstractSplitStrategy splitStrategy = SplitStrategyFactory.build(splitType, scoreStrategy, barrages, duration,liverKeywordMap); if(splitStrategy!=null){ @@ -112,4 +116,8 @@ public class BarrageScoreCurvePlugin extends SpringBootPlugin { public static boolean isBan(String barrage,Map map){ return isBan0(barrage,globalKeywordMap)||isBan0(barrage,map); } + + public List getKetWords(String liver){ + return StringUtils.hasText(liver)?service.getLiverKeyWords(liver):new ArrayList<>(); + } } diff --git a/chopperbot-console/src/main/java/org/example/controller/BarrageController.java b/chopperbot-console/src/main/java/org/example/controller/BarrageController.java new file mode 100644 index 0000000..a4bae76 --- /dev/null +++ b/chopperbot-console/src/main/java/org/example/controller/BarrageController.java @@ -0,0 +1,78 @@ +package org.example.controller; + +import com.genius.assistant.common.Result; +import org.example.bean.BarrageCurveVO; +import org.example.bean.LiverKeyword; +import org.example.constpool.PluginName; +import org.example.plugin.annotation.CheckPlugin; +import org.example.service.BarrageService; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * @author Genius + * @date 2023/10/13 17:52 + **/ +@RestController +@RequestMapping("/barrage") +public class BarrageController { + + @Resource + BarrageService barrageService; + + @CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN}) + @GetMapping("/barrageScoreCurve/curveList") + public Result curveVOList(){ + return Result.success(Map.of("list",barrageService.barrageScoreCurvePluginApi().curveVOList())); + } + + @CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN}) + @GetMapping("/barrageScoreCurve/generate") + public Result generateCurve(@RequestParam String filePath,@RequestParam(required = false) String liver){ + BarrageCurveVO barrageCurveVO = barrageService.barrageScoreCurvePluginApi().generateCurve(filePath, liver); + if(barrageCurveVO==null){ + return Result.error("403","生成失败"); + } + return Result.success(Map.of("curve",barrageCurveVO)); + } + + @CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN}) + @GetMapping("/barrageScoreCurve/keywords") + public Result getKeyWords(@RequestParam(required = false) String liver) { + if (StringUtils.hasText(liver)) { + return Result.success(Map.of("list", barrageService.barrageScoreCurvePluginApi().getKeyWords(liver))); + } else { + return Result.success(Map.of("list", barrageService.barrageScoreCurvePluginApi().getKeyWords())); + } + } + + @CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN}) + @GetMapping("/barrageScoreCurve/delete") + public Result deleteKeyWords(@RequestParam String liver,@RequestParam String keyWord) { + return Result.success(Map.of("success", + barrageService.barrageScoreCurvePluginApi().deleteKeyWord(liver,keyWord))); + } + + @CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN}) + @PostMapping("/barrageScoreCurve/add") + public Result addKeyWords(@RequestBody LiverKeyword keyword) { + return Result.success(Map.of("success", + barrageService.barrageScoreCurvePluginApi().addKeyWord(keyword))); + } + + @CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN}) + @PostMapping("/barrageScoreCurve/update") + public Result updateKeyWords(@RequestBody LiverKeyword keyword) { + return Result.success(Map.of("success", + barrageService.barrageScoreCurvePluginApi().updateKeyWord(keyword))); + } + + @CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN}) + @GetMapping("/barrageScoreCurve/setting") + public Result getSetting(){ + return Result.success(Map.of("curve",barrageService.barrageScoreCurvePluginApi().getSetting())); + } +} diff --git a/chopperbot-console/src/main/java/org/example/service/BarrageService.java b/chopperbot-console/src/main/java/org/example/service/BarrageService.java new file mode 100644 index 0000000..b467e85 --- /dev/null +++ b/chopperbot-console/src/main/java/org/example/service/BarrageService.java @@ -0,0 +1,9 @@ +package org.example.service; + + +import org.example.api.BarrageScoreCurvePluginApi; + +public interface BarrageService { + + public BarrageScoreCurvePluginApi barrageScoreCurvePluginApi(); +} diff --git a/chopperbot-console/src/main/java/org/example/service/impl/BarrageServiceImpl.java b/chopperbot-console/src/main/java/org/example/service/impl/BarrageServiceImpl.java new file mode 100644 index 0000000..ffe811b --- /dev/null +++ b/chopperbot-console/src/main/java/org/example/service/impl/BarrageServiceImpl.java @@ -0,0 +1,24 @@ +package org.example.service.impl; + +import org.example.api.BarrageScoreCurvePluginApi; +import org.example.service.BarrageService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * @author Genius + * @date 2023/10/13 17:53 + **/ +@Service +public class BarrageServiceImpl implements BarrageService { + + @Resource + BarrageScoreCurvePluginApi barrageScoreCurvePluginApi; + + + @Override + public BarrageScoreCurvePluginApi barrageScoreCurvePluginApi() { + return barrageScoreCurvePluginApi; + } +} diff --git a/chopperbot-console/src/main/resources/banner.txt b/chopperbot-console/src/main/resources/banner.txt new file mode 100644 index 0000000..55aa4b6 --- /dev/null +++ b/chopperbot-console/src/main/resources/banner.txt @@ -0,0 +1,9 @@ + ________ ___ ___ ________ ________ ________ _______ ________ ________ ________ _________ +|\ ____\|\ \|\ \|\ __ \|\ __ \|\ __ \|\ ___ \ |\ __ \ |\ __ \|\ __ \|\___ ___\ +\ \ \___|\ \ \\\ \ \ \|\ \ \ \|\ \ \ \|\ \ \ __/|\ \ \|\ \ \ \ \|\ /\ \ \|\ \|___ \ \_| + \ \ \ \ \ __ \ \ \\\ \ \ ____\ \ ____\ \ \_|/_\ \ _ _\ \ \ __ \ \ \\\ \ \ \ \ + \ \ \____\ \ \ \ \ \ \\\ \ \ \___|\ \ \___|\ \ \_|\ \ \ \\ \| \ \ \|\ \ \ \\\ \ \ \ \ + \ \_______\ \__\ \__\ \_______\ \__\ \ \__\ \ \_______\ \__\\ _\ \ \_______\ \_______\ \ \__\ + \|_______|\|__|\|__|\|_______|\|__| \|__| \|_______|\|__|\|__| \|_______|\|_______| \|__| + + diff --git a/chopperbot-creeper/src/main/resources/logback.xml b/chopperbot-creeper/src/main/resources/logback.xml index fe5dfd7..305f641 100644 --- a/chopperbot-creeper/src/main/resources/logback.xml +++ b/chopperbot-creeper/src/main/resources/logback.xml @@ -10,7 +10,6 @@ %red(%d{yyyy-MM-dd HH:mm:ss}) %boldMagenta([%logger]) %highlight(%-5level) - %msg%n - UTF-8 diff --git a/chopperbot-hot/src/main/java/org/example/core/focus/LiverFollower.java b/chopperbot-hot/src/main/java/org/example/core/focus/LiverFollower.java index 29f36b2..6a8b221 100644 --- a/chopperbot-hot/src/main/java/org/example/core/focus/LiverFollower.java +++ b/chopperbot-hot/src/main/java/org/example/core/focus/LiverFollower.java @@ -61,7 +61,7 @@ public class LiverFollower extends SpringBootPlugin { FileCache fileCache = plugin.getFileCache(HotModuleConfig.getFullFilePath()); focusLive = (Integer)fileCache.get("LiverFollower", "focusLive")==1; //focusBarrage = (Integer)fileCache.get("LiverFollower", "focusBarrage")==1; - checkTime = Integer.toUnsignedLong((Integer) fileCache.get("LiverFollower", "checkTime")); + checkTime = Long.parseLong(fileCache.get("LiverFollower", "checkTime").toString()); focusRecord = (Integer)fileCache.get("LiverFollower", "focusRecord")==1; checkTime = (Integer)fileCache.get("LiverFollower", "checkTime"); focusLivers = service.getFocusLivers(); diff --git a/config/Hot/hotModuleConfig.json b/config/Hot/hotModuleConfig.json index c0b3d31..550c308 100644 --- a/config/Hot/hotModuleConfig.json +++ b/config/Hot/hotModuleConfig.json @@ -6,9 +6,9 @@ "LiverFollower":{ "checkTime":120000, "focusRecord":1, - "focusLive":1, + "focusLive":0, "focusBarrage":1 } }, "updateTime":"2023-10-13 15:24:06" -} \ No newline at end of file +} diff --git a/config/chopperBotConfig.json b/config/chopperBotConfig.json index 8fa4040..869cbd8 100644 --- a/config/chopperBotConfig.json +++ b/config/chopperBotConfig.json @@ -31,5 +31,5 @@ "CreeperConfig":true } }, - "updateTime":"2023-10-13 15:23:06" + "updateTime":"2023-10-13 16:27:29" } \ No newline at end of file