mirror of
https://github.com/Geniusay/ChopperBot.git
synced 2026-06-20 16:56:10 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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<BarrageCurveVO> curveVOList(){
|
||||
List<BarrageCurveVO> 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<BarragePoint> points = barrageScoreCurvePlugin.generateCurve(event);
|
||||
return new BarrageCurveVO(filePath,points);
|
||||
}
|
||||
|
||||
public List<LiverKeyword> getKeyWords(String anchor){
|
||||
return barrageScoreCurvePlugin.getKetWords(anchor);
|
||||
}
|
||||
|
||||
public List<LiverKeyword> 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<String,Object> settings){
|
||||
ConfigFileUtil.changeSetting(settings,BarrageModuleConfig.getFullFilePath(),"barrageScoreCurve");
|
||||
}
|
||||
|
||||
public Object getSetting(){
|
||||
return ConfigFileUtil.getSetting(BarrageModuleConfig.getFullFilePath(),"barrageScoreCurve");
|
||||
}
|
||||
}
|
||||
@@ -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<BarragePoint> points;
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<LiverKeyword> liverKeyWords = service.getLiverKeyWords(liver);
|
||||
|
||||
List<LiverKeyword> liverKeyWords = getKetWords(liver);
|
||||
|
||||
Map<String, LiverKeyword> 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<String, LiverKeyword> map){
|
||||
return isBan0(barrage,globalKeywordMap)||isBan0(barrage,map);
|
||||
}
|
||||
|
||||
public List<LiverKeyword> getKetWords(String liver){
|
||||
return StringUtils.hasText(liver)?service.getLiverKeyWords(liver):new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.example.service;
|
||||
|
||||
|
||||
import org.example.api.BarrageScoreCurvePluginApi;
|
||||
|
||||
public interface BarrageService {
|
||||
|
||||
public BarrageScoreCurvePluginApi barrageScoreCurvePluginApi();
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
9
chopperbot-console/src/main/resources/banner.txt
Normal file
9
chopperbot-console/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
________ ___ ___ ________ ________ ________ _______ ________ ________ ________ _________
|
||||
|\ ____\|\ \|\ \|\ __ \|\ __ \|\ __ \|\ ___ \ |\ __ \ |\ __ \|\ __ \|\___ ___\
|
||||
\ \ \___|\ \ \\\ \ \ \|\ \ \ \|\ \ \ \|\ \ \ __/|\ \ \|\ \ \ \ \|\ /\ \ \|\ \|___ \ \_|
|
||||
\ \ \ \ \ __ \ \ \\\ \ \ ____\ \ ____\ \ \_|/_\ \ _ _\ \ \ __ \ \ \\\ \ \ \ \
|
||||
\ \ \____\ \ \ \ \ \ \\\ \ \ \___|\ \ \___|\ \ \_|\ \ \ \\ \| \ \ \|\ \ \ \\\ \ \ \ \
|
||||
\ \_______\ \__\ \__\ \_______\ \__\ \ \__\ \ \_______\ \__\\ _\ \ \_______\ \_______\ \ \__\
|
||||
\|_______|\|__|\|__|\|_______|\|__| \|__| \|_______|\|__|\|__| \|_______|\|_______| \|__|
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<encoder>
|
||||
<pattern>%red(%d{yyyy-MM-dd HH:mm:ss}) %boldMagenta([%logger]) %highlight(%-5level) - %msg%n</pattern>
|
||||
<!--如果线上log日志出现中文乱码,下面这句有关编码设置的要删除或注释掉,原因不明-->
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
"LiverFollower":{
|
||||
"checkTime":120000,
|
||||
"focusRecord":1,
|
||||
"focusLive":1,
|
||||
"focusLive":0,
|
||||
"focusBarrage":1
|
||||
}
|
||||
},
|
||||
"updateTime":"2023-10-13 15:24:06"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,5 +31,5 @@
|
||||
"CreeperConfig":true
|
||||
}
|
||||
},
|
||||
"updateTime":"2023-10-13 15:23:06"
|
||||
"updateTime":"2023-10-13 16:27:29"
|
||||
}
|
||||
Reference in New Issue
Block a user