Merge remote-tracking branch 'origin/master'

This commit is contained in:
Klein
2023-10-31 23:39:32 +08:00
74 changed files with 1271 additions and 235 deletions

View File

@@ -64,7 +64,7 @@
------
## [V 1.0.10] - 2023.7.31
- 🐞Bug:**#00005** 删除config文件无法修复
- ⛏修复:**#00005** 将ModuleSrcConfigInitMachine移除插件范围不作为File模块的插件启动将ModuleSrcConfigInitMachine提前到WorldInit前启动。详情请看 https://github.com/969025903/ChopperBot/issues/5
- ⛏修复:**#00005** 将ModuleSrcConfigInitMachine移除插件范围不作为File模块的插件启动将ModuleSrcConfigInitMachine提前到WorldInit前启动。详情请看 https://github.com/Geniusay/ChopperBot/issues/5
------
## [V 1.0.9] - 2023.7.30
**💥GREAT CHANGE**

View File

@@ -1,5 +1,5 @@
<p align="center">
<a href="https://github.com/969025903/ChopperBot">
<a href="https://github.com/Geniusay/ChopperBot">
<img alt="ChopperBot" src="https://github.com/twj666/ChopperBot-Doc/blob/master/img/logo.png?raw=true">
</a>
</p>
@@ -13,19 +13,19 @@
</audio>
<p align="center">
<a href="https://969025903.github.io/ChopperBot-Doc/">
<a href="https://Geniusay.github.io/ChopperBot-Doc/">
<img src="https://img.shields.io/badge/文档-简体中文-blue.svg" alt="简体中文文档" />
</a>
<a href="https://github.com/969025903/ChopperBot/blob/master/CHANGELOG.md" >
<a href="https://github.com/Geniusay/ChopperBot/blob/master/CHANGELOG.md" >
<img src="https://img.shields.io/badge/ChangeLog-English-blue.svg" alt="Update Log" />
</a>
<a target="_blank" href="https://www.oracle.com/technetwork/java/javase/downloads/index.html">
<img src="https://img.shields.io/badge/JDK-11+-green.svg" />
</a>
<a target="_blank" href='https://github.com/969025903/ChopperBot'>
<img src="https://img.shields.io/github/stars/969025903/ChopperBot.svg" alt="github stars"/>
<a target="_blank" href='https://github.com/Geniusay/ChopperBot'>
<img src="https://img.shields.io/github/stars/Geniusay/ChopperBot.svg" alt="github stars"/>
</a>
<a target="_blank" href=''>
@@ -34,7 +34,7 @@
</p>
<p align='center'>
<b>English</b> | <a href="https://github.com/969025903/ChopperBot/blob/master/README.zh-CN.md">简体中文</a>
<b>English</b> | <a href="https://github.com/Geniusay/ChopperBot/blob/master/README.zh-CN.md">简体中文</a>
</p>
@@ -56,22 +56,22 @@
- **Visualization**: Provide a visual management interface to make your user experience more convenient。
# ⚙ Architecture
![image](https://github.com/969025903/ChopperBot/assets/77137063/eeca58de-611b-41ee-973f-cd375f98e569)
![image](https://github.com/Geniusay/ChopperBot/assets/77137063/eeca58de-611b-41ee-973f-cd375f98e569)
# 🎥 Preview
## Plugin Center
![e6cb59bdbc2db690610d7dec956aed4](https://github.com/969025903/ChopperBot/assets/77137063/ac83fbae-d720-4b98-8701-687436605e97)
![e6cb59bdbc2db690610d7dec956aed4](https://github.com/Geniusay/ChopperBot/assets/77137063/ac83fbae-d720-4b98-8701-687436605e97)
## Task Center
![Task Center](https://github.com/969025903/ChopperBot/assets/77137063/62ab3560-c5c2-4808-be84-a765349e4c39)
![Task Monitor](https://github.com/969025903/ChopperBot/assets/77137063/95843e98-fdc3-4ff4-805a-4a0dd8ef28be)
![Task Center](https://github.com/Geniusay/ChopperBot/assets/77137063/62ab3560-c5c2-4808-be84-a765349e4c39)
![Task Monitor](https://github.com/Geniusay/ChopperBot/assets/77137063/95843e98-fdc3-4ff4-805a-4a0dd8ef28be)
## Creeper Library
![02754f052b22234db1081dec379e8fa](https://github.com/969025903/ChopperBot/assets/77137063/5e12b279-ff34-450f-a408-c4b1f2d797d9)
![02754f052b22234db1081dec379e8fa](https://github.com/Geniusay/ChopperBot/assets/77137063/5e12b279-ff34-450f-a408-c4b1f2d797d9)
## Hot Guard
![9f9a0e3127245ae70e5375c1bf90509](https://github.com/969025903/ChopperBot/assets/77137063/6d8c0f1e-a02f-4d04-a047-f03888358790)
![9f9a0e3127245ae70e5375c1bf90509](https://github.com/Geniusay/ChopperBot/assets/77137063/6d8c0f1e-a02f-4d04-a047-f03888358790)
## Heat Recommend
![431e8b1880825e528b07f9c11360577](https://github.com/969025903/ChopperBot/assets/77137063/adeab4ae-25fe-4752-a6ce-2a79a6f5703e)
![431e8b1880825e528b07f9c11360577](https://github.com/Geniusay/ChopperBot/assets/77137063/adeab4ae-25fe-4752-a6ce-2a79a6f5703e)
## Hot Live
![T4)XK652SFQ1FH7BF53~1 J](https://github.com/969025903/ChopperBot/assets/77137063/6fe79608-6724-4768-8b39-3f4b9b2483c2)
![T4)XK652SFQ1FH7BF53~1 J](https://github.com/Geniusay/ChopperBot/assets/77137063/6fe79608-6724-4768-8b39-3f4b9b2483c2)
**More pages in development....**
# 🕹 ChopperBot Module
@@ -92,18 +92,18 @@
![Alt](https://repobeats.axiom.co/api/embed/0ae23655bb105addf8d90a999df36f690d615af7.svg "Repobeats analytics image")
# 🔗 Links
👉 [Document](https://969025903.github.io/ChopperBot-Doc/)
👉 [Document](https://Geniusay.github.io/ChopperBot-Doc/)
👉 [Developer's Guide](https://969025903.github.io/ChopperBot-Doc/pages/779a67/#chopperbot%E7%B3%BB%E7%BB%9F%E6%9E%B6%E6%9E%84)
👉 [Developer's Guide](https://Geniusay.github.io/ChopperBot-Doc/pages/779a67/#chopperbot%E7%B3%BB%E7%BB%9F%E6%9E%B6%E6%9E%84)
👉 [CHANGE LOG](https://github.com/969025903/ChopperBot/blob/master/CHANGELOG.md)
👉 [CHANGE LOG](https://github.com/Geniusay/ChopperBot/blob/master/CHANGELOG.md)
# 💬Contact Us
- Email: 969025903@qq.com | geniusssbg@gmail.com
- Email: Geniusay@qq.com | geniusssbg@gmail.com
- QQ
<img src="https://github.com/969025903/ChopperBot/assets/77137063/4b18e405-4fd9-43f0-8665-04d3914abbfa" width="25%" height="25%">
<img src="https://github.com/Geniusay/ChopperBot/assets/77137063/4b18e405-4fd9-43f0-8665-04d3914abbfa" width="25%" height="25%">
- Wechat
<img src="https://github.com/969025903/ChopperBot/assets/77137063/1e728690-7565-48c7-9d6f-313cd3409f9b" width="25%" height="25%">
<img src="https://github.com/Geniusay/ChopperBot/assets/77137063/1e728690-7565-48c7-9d6f-313cd3409f9b" width="25%" height="25%">

View File

@@ -1,6 +1,6 @@
<p align="center">
<a href="https://github.com/969025903/ChopperBot">
<a href="https://github.com/Geniusay/ChopperBot">
<img alt="ChopperBot" src="https://github.com/twj666/ChopperBot-Doc/blob/master/img/logo.png?raw=true">
</a>
</p>
@@ -10,19 +10,19 @@
</p>
<p align="center">
<a href="https://969025903.github.io/ChopperBot-Doc/">
<a href="https://Geniusay.github.io/ChopperBot-Doc/">
<img src="https://img.shields.io/badge/文档-简体中文-blue.svg" alt="简体中文文档" />
</a>
<a href="https://github.com/969025903/ChopperBot/blob/master/CHANGELOG.md" >
<a href="https://github.com/Geniusay/ChopperBot/blob/master/CHANGELOG.md" >
<img src="https://img.shields.io/badge/ChangeLog-English-blue.svg" alt="Update Log" />
</a>
<a target="_blank" href="https://www.oracle.com/technetwork/java/javase/downloads/index.html">
<img src="https://img.shields.io/badge/JDK-11+-green.svg" />
</a>
<a target="_blank" href='https://github.com/969025903/ChopperBot'>
<img src="https://img.shields.io/github/stars/969025903/ChopperBot.svg" alt="github stars"/>
<a target="_blank" href='https://github.com/Geniusay/ChopperBot'>
<img src="https://img.shields.io/github/stars/Geniusay/ChopperBot.svg" alt="github stars"/>
</a>
<a target="_blank" href=''>
@@ -31,7 +31,7 @@
</p>
<p align='center'>
<b>简体中文</b> | <a href="https://github.com/969025903/ChopperBot/blob/master/README.md">English</a>
<b>简体中文</b> | <a href="https://github.com/Geniusay/ChopperBot/blob/master/README.md">English</a>
</p>
@@ -53,22 +53,22 @@
- **可视化管理**: 提供可视化管理界面,让您的使用体验更方便。
# ⚙ 系统架构
![image](https://github.com/969025903/ChopperBot/assets/77137063/eeca58de-611b-41ee-973f-cd375f98e569)
![image](https://github.com/Geniusay/ChopperBot/assets/77137063/eeca58de-611b-41ee-973f-cd375f98e569)
# 🎥 项目预览
## 插件中心
![e6cb59bdbc2db690610d7dec956aed4](https://github.com/969025903/ChopperBot/assets/77137063/ac83fbae-d720-4b98-8701-687436605e97)
![e6cb59bdbc2db690610d7dec956aed4](https://github.com/Geniusay/ChopperBot/assets/77137063/ac83fbae-d720-4b98-8701-687436605e97)
## 爬虫任务中心
![Task Center](https://github.com/969025903/ChopperBot/assets/77137063/62ab3560-c5c2-4808-be84-a765349e4c39)
![Task Monitor](https://github.com/969025903/ChopperBot/assets/77137063/95843e98-fdc3-4ff4-805a-4a0dd8ef28be)
![Task Center](https://github.com/Geniusay/ChopperBot/assets/77137063/62ab3560-c5c2-4808-be84-a765349e4c39)
![Task Monitor](https://github.com/Geniusay/ChopperBot/assets/77137063/95843e98-fdc3-4ff4-805a-4a0dd8ef28be)
## 爬虫仓库
![02754f052b22234db1081dec379e8fa](https://github.com/969025903/ChopperBot/assets/77137063/5e12b279-ff34-450f-a408-c4b1f2d797d9)
![02754f052b22234db1081dec379e8fa](https://github.com/Geniusay/ChopperBot/assets/77137063/5e12b279-ff34-450f-a408-c4b1f2d797d9)
## 平台热门监控
![9f9a0e3127245ae70e5375c1bf90509](https://github.com/969025903/ChopperBot/assets/77137063/6d8c0f1e-a02f-4d04-a047-f03888358790)
![9f9a0e3127245ae70e5375c1bf90509](https://github.com/Geniusay/ChopperBot/assets/77137063/6d8c0f1e-a02f-4d04-a047-f03888358790)
## 热门直播推荐
![431e8b1880825e528b07f9c11360577](https://github.com/969025903/ChopperBot/assets/77137063/adeab4ae-25fe-4752-a6ce-2a79a6f5703e)
![431e8b1880825e528b07f9c11360577](https://github.com/Geniusay/ChopperBot/assets/77137063/adeab4ae-25fe-4752-a6ce-2a79a6f5703e)
## 多平台热门直播
![T4)XK652SFQ1FH7BF53~1 J](https://github.com/969025903/ChopperBot/assets/77137063/6fe79608-6724-4768-8b39-3f4b9b2483c2)
![T4)XK652SFQ1FH7BF53~1 J](https://github.com/Geniusay/ChopperBot/assets/77137063/6fe79608-6724-4768-8b39-3f4b9b2483c2)
**更多页面正在开发中....**
# 🕹 ChopperBot模块介绍
@@ -88,18 +88,18 @@
# 📈 项目动态
![Alt](https://repobeats.axiom.co/api/embed/0ae23655bb105addf8d90a999df36f690d615af7.svg "Repobeats analytics image")
# 🔗 相关链接
👉 [项目文档](https://969025903.github.io/ChopperBot-Doc/)
👉 [项目文档](https://Geniusay.github.io/ChopperBot-Doc/)
👉 [项目开发指南](https://969025903.github.io/ChopperBot-Doc/pages/779a67/#chopperbot%E7%B3%BB%E7%BB%9F%E6%9E%B6%E6%9E%84)
👉 [项目开发指南](https://Geniusay.github.io/ChopperBot-Doc/pages/779a67/#chopperbot%E7%B3%BB%E7%BB%9F%E6%9E%B6%E6%9E%84)
👉 [更新日志](https://github.com/969025903/ChopperBot/blob/master/CHANGELOG.md)
👉 [更新日志](https://github.com/Geniusay/ChopperBot/blob/master/CHANGELOG.md)
# 💬联系我们
- Email: 969025903@qq.com | geniusssbg@gmail.com
- Email: Geniusay@qq.com | geniusssbg@gmail.com
- QQ
<img src="https://github.com/969025903/ChopperBot/assets/77137063/4b18e405-4fd9-43f0-8665-04d3914abbfa" width="25%" height="25%">
<img src="https://github.com/Geniusay/ChopperBot/assets/77137063/4b18e405-4fd9-43f0-8665-04d3914abbfa" width="25%" height="25%">
- Wechat
<img src="https://github.com/969025903/ChopperBot/assets/77137063/1e728690-7565-48c7-9d6f-313cd3409f9b" width="25%" height="25%">
<img src="https://github.com/Geniusay/ChopperBot/assets/77137063/1e728690-7565-48c7-9d6f-313cd3409f9b" width="25%" height="25%">

View File

@@ -0,0 +1,44 @@
package org.example.api;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.example.core.label.LabelManagerPlugin;
import org.example.pojo.VideoLabel;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* @author Genius
* @date 2023/10/23 17:22
**/
@Component
public class LabelManagerPluginApi {
@Resource
LabelManagerPlugin plugin;
public List<VideoLabel> labelList(){
return plugin.getMapper().selectList(new QueryWrapper<>());
}
public VideoLabel addLabel(VideoLabel label){
try {
label.setLabelId(UUID.randomUUID().toString());
if (plugin.getMapper().insert(label)>0) {
return label;
}
}catch (Exception e){
}
return null;
}
public boolean deleteLabel(String label){
return plugin.getMapper().deleteByMap(Map.of("label",label))>0;
}
public boolean updateLabel(VideoLabel label){
return plugin.getMapper().update(label,new QueryWrapper<VideoLabel>().eq("label_id",label.getLabelId()))>0;
}
}

View File

@@ -8,6 +8,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* @Date 2023/10/12
@@ -22,6 +23,9 @@ public class OpenAPIPluginApi {
return plugin.getMapper().update(newKey, new QueryWrapper<GPTKey>().eq("function", newKey.getFunction())) == 1;
}
public boolean deleteKey(String function){
return plugin.getMapper().deleteByMap(Map.of("function",function))==1;
}
public boolean addKey(GPTKey key){
return plugin.getMapper().insert(key)==1;
}

View File

@@ -35,6 +35,7 @@ public class ChatGPTMsgBuilder extends AbstractMsgBuilder {
@Override
public String done() {
build("temperature",1);
this.map.put("messages", List.of(system,user));
return super.done();
}

View File

@@ -10,12 +10,12 @@ import org.example.mapper.GPTKeyMapper;
import org.example.plugin.SpringBootPlugin;
import org.example.pojo.GPTKey;
import org.example.sql.annotation.SQLInit;
import org.example.util.ExceptionUtil;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -68,22 +68,20 @@ public class OpenAPIPlugin extends SpringBootPlugin {
try (Response response = client.newCall(request).execute()){
if (response.body() != null) {
String content = response.body().string();
if(content.contains("error")){
this.error("OpenAI API 调用错误!",String.format("OpenAI API 调用错误,原因:%s", content),true);
}
return JSONObject.parseObject(content);
}
} catch (IOException e) {
this.error(String.format("Error: api request fail,Cause:%s", e.getCause()));
this.error(String.format("Error: api request fail,Cause:%s", ExceptionUtil.getCause(e)));
}
return null;
}
public String getCommonRes(JSONObject resp){
Pattern pattern = Pattern.compile("\\[(.*?)]");
Matcher matcher = pattern.matcher(resp.getJSONArray("choices").getJSONObject(0).getJSONObject("message").getString("content"));
if (matcher.find()) return matcher.group(1);
return "";
return resp.getJSONArray("choices").getJSONObject(0).getJSONObject("message").getString("content");
}
private RequestBody buildBody(String msg){
@@ -115,6 +113,17 @@ public class OpenAPIPlugin extends SpringBootPlugin {
return Arrays.stream(APIFunc.values()).map(APIFunc::funcName).collect(Collectors.toList());
}
public static List<String> zipContent(List<String> contents){
Set<String> zipContent = new TreeSet<>(contents);
return new ArrayList<>(zipContent);
}
public static String zipContent(String contents){
if(contents.length()>3000){
return contents.substring(0,3000);
}
return contents;
}
@Override
@SQLInit(table = "gpt_key",tableSQL = "CREATE TABLE \"gpt_key\" (\n" +
"\t\"key\"\tTEXT NOT NULL,\n" +
@@ -123,6 +132,6 @@ public class OpenAPIPlugin extends SpringBootPlugin {
"\t\"function\"\tTEXT NOT NULL DEFAULT 'chatgpt' UNIQUE\n" +
")",mapper = GPTKeyMapper.class)
public List<GPTKey> sqlInit() {
return List.of(new GPTKey("sk-xgUDtOdRgQLigz2D0e4cA665441e4287AfCf8458B1C21b0f","https://oneapi.a9.gay/v1/chat/completions","gpt-3.5-turbo",APIFunc.CHAT_GPT.funcName()));
return List.of(new GPTKey("sk-xgUDtOdRgQLigz2D0e4cA665441e4287AfCf8458B1C21b0f","https://oneapi.a9.gay/v1/chat/completions","gpt-4",APIFunc.CHAT_GPT.funcName()));
}
}

View File

@@ -1,6 +1,7 @@
package org.example.core.label;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import org.example.mapper.LabelMapper;
import org.example.plugin.SpringBootPlugin;
import org.example.pojo.VideoLabel;
@@ -11,6 +12,7 @@ import javax.annotation.Resource;
import java.awt.*;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
/**
@@ -18,6 +20,7 @@ import java.util.stream.Collectors;
* @date 2023/10/23 00:10
**/
@Component
@Data
public class LabelManagerPlugin extends SpringBootPlugin {
@Resource
@@ -31,32 +34,19 @@ public class LabelManagerPlugin extends SpringBootPlugin {
@Override
@SQLInit(table = "video_label",tableSQL = "CREATE TABLE \"video_label\" (\n" +
"\t\"id\"\tINTEGER NOT NULL,\n" +
"\t\"label_id\"\tTEXT NOT NULL UNIQUE,\n" +
"\t\"label\"\tTEXT NOT NULL UNIQUE,\n" +
"\tPRIMARY KEY(\"id\" AUTOINCREMENT)\n" +
")",mapper = LabelMapper.class)
public List<?> sqlInit() {
return List.of(new VideoLabel(null,"搞笑"),
new VideoLabel(null,"破防"),new VideoLabel(null,"泪目"),
new VideoLabel(null,"精彩操作"));
return List.of(new VideoLabel(null, UUID.randomUUID().toString(),"搞笑"),
new VideoLabel(null, UUID.randomUUID().toString(),"破防"),
new VideoLabel(null, UUID.randomUUID().toString(),"泪目"),
new VideoLabel(null, UUID.randomUUID().toString(),"精彩操作"));
}
public List<String> labelStrList(){
return mapper.selectList(new QueryWrapper<>()).stream().map(VideoLabel::getLabel).collect(Collectors.toList());
}
public List<VideoLabel> labelList(){
return mapper.selectList(new QueryWrapper<>());
}
public boolean addLabel(VideoLabel label){
return mapper.insert(label)>0;
}
public boolean deleteLabel(String label){
return mapper.deleteByMap(Map.of("label",label))>0;
}
public boolean updateLabel(VideoLabel label){
return mapper.update(label,new QueryWrapper<VideoLabel>().eq("id",label.getId()))>0;
}
}

View File

@@ -15,5 +15,6 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
public class VideoLabel {
private Integer id;
private String labelId;
private String label;
}

View File

@@ -52,20 +52,6 @@ public class LiveAndBarrageHandlerObserver extends AbstractTaskCenterObserver {
((BarrageEventCenter)plugin).event(event);
}
},PluginName.BARRAGE_EVENT_PLUGIN);
} else{
PluginCheckAndDo.CheckAndDo(plugin -> {
Object param = task.getRequest().getParam();
if(param instanceof Live){
SectionRequest request = ((VideoSectionWorkShop)plugin).wrapperReq((Live)param,task.getLoadConfig().getSuffix()
,"online",
task.getLoadConfig().getStartTime(),
0,TimeUtil.getTimeNaos(task.getEndTime())
);
((VideoSectionWorkShop)plugin).request(request);
}
},PluginName.VIDEO_SECTION_WORK_SHOP);
}
}

View File

@@ -93,11 +93,14 @@ public class BarrageEventCenter extends SpringBootPlugin {
String fileName = event.getFileName().split("\\.")[0]+suffix;
String date = event.getDate();
SectionRequest request = new SectionRequest(fileName, action, popularRange.getStartTime(), popularRange.getEndTime(), liver, platform,date);
for (BarragePoint point : popularRange.getList()) {
List<String> barrages = point.getBarrages();
request.getBarrages().addAll(barrages);
}
((VideoSectionWorkShop)plugin).request(request);
}
},PluginName.VIDEO_SECTION_WORK_SHOP);
}
//TODO 弹幕标签插件
}
}

View File

@@ -35,7 +35,7 @@ public class PluginAspect {
for (String plugin : annotation.needPlugin()) {
if(!InitPluginRegister.isRegister(plugin)){
throw new PluginNotRegisterException();
throw new PluginNotRegisterException(annotation.needPlugin());
}
}
}

View File

@@ -0,0 +1,22 @@
package org.example.bean.section;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author Genius
* @date 2023/10/25 17:59
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PackageSection extends VideoSection{
private String title;
private String description;
private String coverPath;
private String content;
private List<String> labels;
}

View File

@@ -1,9 +1,16 @@
package org.example.core.section;
package org.example.bean.section;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.bean.Barrage;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
@@ -13,12 +20,16 @@ import java.util.List;
**/
@Data
@TableName("section_parking")
@NoArgsConstructor
@AllArgsConstructor
public class VideoSection {
private String videoPath;
private String tag;
private String liver;
private List<Barrage> barrages;
private String barrageFile;
@TableField(exist = false)
private List<String> barrages;
private String platform;
public VideoSection(String videoPath, String tag, String liver, String platform) {

View File

@@ -45,8 +45,6 @@ public class PluginName {
public static final String CHAT_GPT = "OpenAPI";
public static final String EMOTION_ANALYSIS = "EmotionAnalysis";
public static final String ACCOUNT_MANAGER = "AccountManager";
public static final String LABEL_MANAGER = "LabelManager";
@@ -56,4 +54,9 @@ public class PluginName {
public static final String LIVE_MANAGER_PLUGIN= "LiveDownLoadManager";
public static final String VIDEO_SECTION_WORK_SHOP = "SectionWorkShop";
public static final String EMOTION_ANALYSIS = "EmotionAnalysis";
public static final String TITLE_GENERATE = "TitleGenerate";
public static final String DESC_GENERATE = "DescriptionGenerate";
}

View File

@@ -2,14 +2,24 @@ package org.example.exception.plugin;
import org.example.exception.Impl.ResultCode;
import java.util.Arrays;
import java.util.stream.Collectors;
/**
* @author Genius
* @date 2023/08/02 16:59
**/
public class PluginNotRegisterException extends PluginException{
private String pluginName[];
public PluginNotRegisterException() {
super("Error! Plugin Not Register!");
resultCode = ResultCode.PLUGIN_NOT_REGISTER;
}
public PluginNotRegisterException(String...pluginName) {
super(String.format("Error! %s Plugin Not Register!",Arrays.stream(pluginName).collect(Collectors.toList()).toString()));
resultCode = ResultCode.PLUGIN_NOT_REGISTER;
this.pluginName = pluginName;
}
}

View File

@@ -19,11 +19,16 @@ public class OkHttpAgent implements ProxyAgent<OkHttpClient>{
@Override
public OkHttpClient agentClient() {
OkHttpClient.Builder builder;
if(httpProxy.isEnable()){
Proxy proxy = httpProxy.httpProxy();
return new OkHttpClient.Builder().proxy(proxy).connectTimeout(60, TimeUnit.SECONDS).build();
builder = new OkHttpClient.Builder().proxy(proxy);
}else{
return new OkHttpClient.Builder().build();
builder = new OkHttpClient.Builder();
}
return builder.connectTimeout(120,TimeUnit.SECONDS)
.readTimeout(60,TimeUnit.SECONDS)
.writeTimeout(60,TimeUnit.SECONDS)
.build();
}
}

View File

@@ -1,12 +1,12 @@
package org.example.util;
import org.example.bean.section.VideoSection;
import org.reflections.Reflections;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.lang.reflect.Field;
import java.util.*;
/**
* @author Genius
@@ -71,4 +71,55 @@ public class ClassUtil {
// return List.of(objects);
return set;
}
public static Map<String, Object> toMap(Object obj) throws IllegalAccessException {
Map<String, Object> map = new HashMap<>();
Class<?> clazz = obj.getClass();
for (Field field : clazz.getDeclaredFields()) {
field.setAccessible(true);
map.put(field.getName(), field.get(obj));
}
return map;
}
public static Map<String, Object> toDeepMap(Object obj) throws IllegalAccessException {
Map<String, Object> map = new HashMap<>();
Class<?> clazz = obj.getClass();
// 获取当前类的字段
for (Field field : clazz.getDeclaredFields()) {
field.setAccessible(true);
map.put(field.getName(), field.get(obj));
}
// 如果有父类且不是 Object 类,递归调用获取父类的字段
Class<?> superClass = clazz.getSuperclass();
if (superClass != null && !superClass.equals(Object.class)) {
try {
Object superObj = superClass.getDeclaredConstructor().newInstance();
copyFields(superObj, obj, superClass);
map.putAll(toDeepMap(superObj));
} catch (Exception e) {
e.printStackTrace();
}
}
return map;
}
private static void copyFields(Object dest, Object source, Class<?> clazz) throws IllegalAccessException {
for (Field field : clazz.getDeclaredFields()) {
field.setAccessible(true);
Field destField;
try {
destField = dest.getClass().getDeclaredField(field.getName());
destField.setAccessible(true);
destField.set(dest, field.get(source));
} catch (NoSuchFieldException e) {
// 忽略字段不存在的异常
}
}
}
}

View File

@@ -0,0 +1,14 @@
package org.example.util;
import java.util.Map;
import java.util.Optional;
/**
* @author Genius
* @date 2023/10/25 18:44
**/
public class MapUtil {
public static String getString(Map<String,Object> map, String key){
return Optional.ofNullable(map.get(key)).orElse("").toString();
}
}

View File

@@ -0,0 +1,14 @@
package org.example.util;
/**
* @author Genius
* @date 2023/10/25 21:31
**/
public class StringUtil {
public static String lowerCaseFirstLetter(String input){
if (input == null || input.isEmpty()) {
return input;
}
return Character.toLowerCase(input.charAt(0)) + input.substring(1);
}
}

View File

@@ -1,9 +1,11 @@
package org.example.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.example.pojo.Account;
import org.example.pojo.AccountVO;
import org.example.pojo.GPTKey;
import org.example.pojo.VideoLabel;
import org.example.service.AccountService;
import org.example.util.Result;
import org.springframework.web.bind.annotation.*;
@@ -47,11 +49,16 @@ public class AccountController {
return Result.success();
}
@GetMapping(value = "/gpt/key")
@GetMapping(value = "/gpt/keys")
public Result getGPT(){
return Result.success(Map.of("list",accountService.chatGptPlugin().getKeys()));
}
@GetMapping(value = "/gpt/delete")
public Result deleteGPT(@RequestParam String function){
return Result.success(Map.of("success",accountService.chatGptPlugin().deleteKey(function)));
}
@PostMapping(value = "/gpt/add")
public Result addGPT(@RequestBody GPTKey key){
boolean b = accountService.chatGptPlugin().addKey(key);
@@ -63,4 +70,32 @@ public class AccountController {
boolean b = accountService.chatGptPlugin().changeKey(key);
return Result.success(Map.of("success",b));
}
@GetMapping(value = "/gpt/functions")
public Result getFunctions(){
return Result.success(Map.of("list",accountService.chatGptPlugin().functions()));
}
@GetMapping(value = "/label/list")
public Result labelList(){
return Result.success(Map.of("list",accountService.labelManagerPlugin().labelList()));
}
@PostMapping(value = "/label/add")
public Result addLabel(@RequestBody VideoLabel label){
if (accountService.labelManagerPlugin().addLabel(label)==null) {
return Result.error("添加失败");
}
return Result.success(Map.of("data",label));
}
@GetMapping(value = "/label/delete")
public Result deleteLabel(@RequestParam String label){
return Result.success(Map.of("success",accountService.labelManagerPlugin().deleteLabel(label)));
}
@PostMapping(value = "/label/update")
public Result updateLabel(@RequestBody VideoLabel label){
return Result.success(Map.of("success",accountService.labelManagerPlugin().updateLabel(label)));
}
}

View File

@@ -7,6 +7,7 @@ import org.example.exception.plugin.PluginException;
import org.example.exception.plugin.PluginNotRegisterException;
import org.example.log.ChopperLogFactory;
import org.example.log.LoggerType;
import org.example.util.ExceptionUtil;
import org.example.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,10 +33,10 @@ public class GlobalExceptionHandler {
@ExceptionHandler(PluginException.class)
public Result handlerPluginException(HttpServletRequest request,PluginException ex){
logger.error("Handle Exception Request Url:{},Exception:{}", request.getRequestURL(), ex);
logger.error("Handle Exception Request Url:{},Exception:{}", request.getRequestURL(), ExceptionUtil.getCause(ex));
if(ex instanceof PluginNotRegisterException){
PluginNotRegisterException exception = (PluginNotRegisterException) ex;
return Result.error(exception.getResultCode());
return Result.error(exception.getResultCode(),ExceptionUtil.getCause(ex));
}else if(ex instanceof PluginDependOnException){
PluginDependOnException exception = (PluginDependOnException) ex;
String msg = "[%s] plugin depend on [%s]!";

View File

@@ -20,7 +20,7 @@ import java.util.function.Supplier;
@Component
public class WorldInitMachine extends ModuleInitMachine{
private static final String githubUrl = "https://github.com/969025903/ChopperBot";
private static final String githubUrl = "https://github.com/Geniusay/ChopperBot";
public WorldInitMachine() throws Exception {
super("ChopperBot",ChopperLogFactory.getLogger(LoggerType.System));

View File

@@ -3,6 +3,7 @@ package org.example.service;
import org.example.api.AccountApi;
import org.example.api.LabelManagerPluginApi;
import org.example.api.OpenAPIPluginApi;
/**
@@ -15,4 +16,6 @@ public interface AccountService {
AccountApi accountPlugin();
OpenAPIPluginApi chatGptPlugin();
LabelManagerPluginApi labelManagerPlugin();
}

View File

@@ -2,6 +2,7 @@ package org.example.service.impl;
import org.example.api.AccountApi;
import org.example.api.LabelManagerPluginApi;
import org.example.api.OpenAPIPluginApi;
import org.example.service.AccountService;
@@ -22,6 +23,9 @@ public class AccountServiceImpl implements AccountService {
@Resource
OpenAPIPluginApi openAPIPluginApi;
@Resource
LabelManagerPluginApi labelManagerPluginApi;
@Override
public AccountApi accountPlugin() {
return accountApi;
@@ -31,4 +35,9 @@ public class AccountServiceImpl implements AccountService {
public OpenAPIPluginApi chatGptPlugin() {
return openAPIPluginApi;
}
@Override
public LabelManagerPluginApi labelManagerPlugin() {
return labelManagerPluginApi;
}
}

View File

@@ -12,12 +12,12 @@ import org.springframework.stereotype.Component;
* @author Genius
* @date 2023/10/16 23:06
**/
@Component
@Component
public class HuyaLiverCheckerBuilder extends CommonLoadConfigBuilder<HuyaLiverCheckerConfig> {
@Override
public HuyaLiverCheckerConfig build(Object obj) {
if(obj instanceof FocusLiver){
return new HuyaLiverCheckerConfig(((HuyaLive) obj).getLiveId());
return new HuyaLiverCheckerConfig(((FocusLiver) obj).getRoomId());
}else if(obj instanceof HuyaLive){
return new HuyaLiverCheckerConfig(((HuyaLive) obj).getLiveId());
}

View File

@@ -37,6 +37,7 @@ public class FocusLiverServiceImpl extends ServiceImpl<FocusLiverMapper,FocusLiv
@Override
public boolean addLivers(FocusLiver liver) {
liver.setId(null);
if(hasLivers(liver.getLiver(),liver.getRoomId())){
return false;
}

View File

@@ -0,0 +1,67 @@
package org.example.core.auto;
import org.example.bean.section.VideoSection;
import org.example.plugin.SpringBootPlugin;
import org.example.util.ExceptionUtil;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author Genius
* @date 2023/10/25 20:41
**/
public abstract class AbstractGeneratePlugin<G extends SectionGenerator<?>> extends SpringBootPlugin implements SectionPipeline{
@Resource
protected Map<String, G> generatorMap;
private G generator;
protected String type;
@Override
public boolean init() {
if(!StringUtils.hasText(type)){
generatorMap.forEach((k,v)->{
this.type = k;
this.generator = v;
});
}else{
this.generator = generatorMap.get(type);
}
if(generator==null){
throw new RuntimeException("Invalid generator type");
}
generator.sqlInit();
return super.init();
}
@Override
public <T extends VideoSection, V extends VideoSection> T process(V section) {
generator.preGenerate();
try {
return generator.generator(section);
}catch (Exception e){
this.info("生成失败", String.format("生成失败,原因:%s", ExceptionUtil.getCause(e)),true);
return (T) section;
}
}
public boolean changeType(String type){
if(generatorMap.containsKey(this.type)){
this.generator = generatorMap.get(this.type);
generator.sqlInit();
this.type = type;
return true;
}
return false;
}
public List<String> types(){
return new ArrayList<>(generatorMap.keySet());
}
}

View File

@@ -1,5 +1,9 @@
package org.example.core.auto;
import java.util.Map;
public interface AutoGenerator <T>{
T generate(Object data);
void preGenerate();
T generate(Map<String,Object> data);
}

View File

@@ -0,0 +1,17 @@
package org.example.core.auto;
import org.example.bean.section.PackageSection;
import org.example.bean.section.VideoSection;
import org.example.sql.SQLInitMachine;
import org.example.util.ClassUtil;
import org.springframework.beans.BeanUtils;
import java.util.Map;
/**
* @author Genius
* @date 2023/10/25 20:42
**/
public abstract class SectionGenerator<R> implements AutoGenerator<R>,SQLInitMachine {
public abstract <T extends VideoSection,V extends VideoSection> V generator(T section);
}

View File

@@ -0,0 +1,8 @@
package org.example.core.auto;
import org.example.bean.section.PackageSection;
import org.example.bean.section.VideoSection;
public interface SectionPipeline {
<O extends VideoSection,I extends VideoSection> O process(I section);
}

View File

@@ -0,0 +1,29 @@
package org.example.core.auto.video.description;
import org.example.bean.section.PackageSection;
import org.example.bean.section.VideoSection;
import org.example.core.auto.SectionGenerator;
import org.example.util.ClassUtil;
import org.springframework.beans.BeanUtils;
import java.util.Map;
/**
* @author Genius
* @date 2023/10/25 20:38
**/
public abstract class DescGenerator extends SectionGenerator<String> {
@Override
public <T extends VideoSection, V extends VideoSection> V generator(T section) {
PackageSection packageSection = new PackageSection();
BeanUtils.copyProperties(section,packageSection);
try {
Map<String, Object> map = ClassUtil.toDeepMap(packageSection);
String desc = this.generate(map);
packageSection.setDescription(desc);
}catch (Exception e){
return (V) section;
}
return (V) packageSection;
}
}

View File

@@ -0,0 +1,26 @@
package org.example.core.auto.video.description;
import org.example.core.auto.AbstractGeneratePlugin;
import org.example.core.auto.video.title.GptTitleGenerator;
import org.example.util.StringUtil;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Map;
/**
* @author Genius
* @date 2023/10/25 21:16
**/
@Component
public class DescGeneratorPlugin extends AbstractGeneratePlugin<DescGenerator> {
@Resource
Map<String,DescGenerator> descGeneratorMap;
@Override
public boolean init() {
this.generatorMap = descGeneratorMap;
this.type = StringUtil.lowerCaseFirstLetter(GptDescGenerator.class.getSimpleName());
return super.init();
}
}

View File

@@ -0,0 +1,91 @@
package org.example.core.auto.video.description;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.example.constpool.PluginName;
import org.example.core.gpt.ChatGPTMsgBuilder;
import org.example.core.gpt.OpenAPIPlugin;
import org.example.exception.plugin.PluginDependOnException;
import org.example.init.InitPluginRegister;
import org.example.mapper.DescSchemeMapper;
import org.example.mapper.TitleSchemeMapper;
import org.example.plugin.PluginCheckAndDo;
import org.example.pojo.DescScheme;
import org.example.pojo.GPTKey;
import org.example.pojo.TitleScheme;
import org.example.sql.annotation.SQLInit;
import org.example.util.ExceptionUtil;
import org.example.util.MapUtil;
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/25 20:55
**/
@Component
public class GptDescGenerator extends DescGenerator {
@Resource
DescSchemeMapper mapper;
private List<DescScheme> schemeList;
public GptDescGenerator() {
this.schemeList = new ArrayList<>();
}
@Override
@SQLInit(table = "desc_scheme",tableSQL = "CREATE TABLE \"desc_scheme\" (\n" +
"\t\"id\"\tINTEGER NOT NULL,\n" +
"\t\"system\"\tTEXT NOT NULL,\n" +
"\t\"type\"\tTEXT,\n" +
"\tPRIMARY KEY(\"id\" AUTOINCREMENT)\n" +
")",mapper = DescSchemeMapper.class)
public List<?> sqlInit() {
return List.of(new DescScheme(null,"作为一个资深的直播运营人员请你根据我提供给你的直播弹幕内容标签和主播来叙述一下该段直播发生了什么事情叙述过程要有趣符合当前短视频快节奏和吸引眼球的风格生成一个即可不需要任何标识和说明字数不超过100字"
,"global"));
}
@Override
public void preGenerate() {
if (!InitPluginRegister.isRegister(PluginName.CHAT_GPT)) {
throw PluginDependOnException.MissingFatherPlugin(PluginName.CHAT_GPT,"");
}
try {
schemeList = mapper.selectList(new QueryWrapper<>());
}catch (Exception e){
throw new RuntimeException("读取desc_scheme表失败");
}
}
@Override
public String generate(Map<String, Object> data) {
if (schemeList.isEmpty())return "";
try {
return PluginCheckAndDo.CheckAndGet((plugin)->{
String liver = MapUtil.getString(data,"liver");
Object barrages = data.get("barrages");
String barrageStr = "";
if(barrages instanceof List){
barrageStr = OpenAPIPlugin.zipContent(OpenAPIPlugin.zipContent((List) barrages).toString());
}
String content = MapUtil.getString(data,"content");
GPTKey gptKey = ((OpenAPIPlugin) plugin).choseKey(OpenAPIPlugin.APIFunc.CHAT_GPT);
DescScheme scheme = schemeList.get(0);
if(gptKey==null)return "";
ChatGPTMsgBuilder builder = new ChatGPTMsgBuilder().model(gptKey.getModel())
.system(scheme.getSystem())
.user(String.format("主播:%s\n内容%s\n直播弹幕%s", liver,content,barrageStr))
.stream(false);
JSONObject object = ((OpenAPIPlugin) plugin).reqGPT(builder, OpenAPIPlugin.APIFunc.CHAT_GPT);
return ((OpenAPIPlugin) plugin).getCommonRes(object);
},PluginName.CHAT_GPT,String.class);
} catch (Exception e){
throw new RuntimeException(ExceptionUtil.getCause(e));
}
}
}

View File

@@ -0,0 +1,36 @@
package org.example.core.auto.video.description;
import org.example.util.MapUtil;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
* @author Genius
* @date 2023/10/25 21:17
**/
@Component
public class RandomDescGenerator extends DescGenerator{
@Override
public List<?> sqlInit() {
return null;
}
@Override
public void preGenerate() {
}
@Override
public String generate(Map<String, Object> data) {
try {
String liver = MapUtil.getString(data,"liver");
return String.format("%s直播精彩集锦",liver);
} catch (Exception e){
return "";
}
}
}

View File

@@ -1,28 +1,42 @@
package org.example.core.auto.video.title;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.example.constpool.PluginName;
import org.example.core.auto.SectionPipeline;
import org.example.core.gpt.ChatGPTMsgBuilder;
import org.example.core.gpt.OpenAPIPlugin;
import org.example.core.label.LabelManagerPlugin;
import org.example.exception.plugin.PluginDependOnException;
import org.example.exception.plugin.PluginNotRegisterException;
import org.example.init.InitPluginRegister;
import org.example.mapper.TitleSchemeMapper;
import org.example.plugin.PluginCheckAndDo;
import org.example.pojo.GPTKey;
import org.example.pojo.TitleScheme;
import org.example.sql.SQLInitMachine;
import org.example.sql.annotation.SQLInit;
import org.example.util.ClassUtil;
import org.example.util.ExceptionUtil;
import org.example.util.MapUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author Genius
* @date 2023/10/22 18:03
**/
@Component
public class GptTitleGenerator implements TitleGenerator{
public class GptTitleGenerator extends TitleGenerator{
@Resource
TitleSchemeMapper titleSchemeMapper;
TitleSchemeMapper mapper;
private List<TitleScheme> schemeList;
public GptTitleGenerator() {
@@ -30,8 +44,43 @@ public class GptTitleGenerator implements TitleGenerator{
}
@Override
public String generate(Object data) {
return null;
public String generate(Map<String,Object> data) {
if (schemeList.isEmpty())return "";
try {
return PluginCheckAndDo.CheckAndGet((plugin)->{
Object barrages = data.get("barrages");
String barrageStr = "";
if(barrages instanceof List){
barrageStr = OpenAPIPlugin.zipContent(OpenAPIPlugin.zipContent((List) barrages).toString());
}
String content = MapUtil.getString(data,"content");
String liver = MapUtil.getString(data,"liver");
String labels = MapUtil.getString(data,"labels");
GPTKey gptKey = ((OpenAPIPlugin) plugin).choseKey(OpenAPIPlugin.APIFunc.CHAT_GPT);
TitleScheme scheme = schemeList.get(0);
if(gptKey==null)return "";
ChatGPTMsgBuilder builder = new ChatGPTMsgBuilder().model(gptKey.getModel())
.system(scheme.getSystem())
.user(String.format("主播:%s\n内容%s\n类型%s\n弹幕%s\n", liver,content,labels,barrageStr))
.stream(false);
JSONObject object = ((OpenAPIPlugin) plugin).reqGPT(builder, OpenAPIPlugin.APIFunc.CHAT_GPT);
return ((OpenAPIPlugin) plugin).getCommonRes(object);
},PluginName.CHAT_GPT,String.class);
} catch (Exception e){
throw new RuntimeException(ExceptionUtil.getCause(e));
}
}
@Override
public void preGenerate() {
if (!InitPluginRegister.isRegister(PluginName.CHAT_GPT)) {
throw PluginDependOnException.MissingFatherPlugin(PluginName.CHAT_GPT,"");
}
try {
schemeList = mapper.selectList(new QueryWrapper<>());
}catch (Exception e){
throw new RuntimeException("读取title_scheme表失败");
}
}
@Override
@@ -41,21 +90,8 @@ public class GptTitleGenerator implements TitleGenerator{
"\t\"type\"\tTEXT,\n" +
"\tPRIMARY KEY(\"id\" AUTOINCREMENT)\n" +
")",mapper = TitleSchemeMapper.class)
public Object preGenerate() {
if (!InitPluginRegister.isRegister(PluginName.CHAT_GPT)) {
throw PluginDependOnException.MissingFatherPlugin(PluginName.CHAT_GPT,"");
}
try {
schemeList = titleSchemeMapper.selectList(new QueryWrapper<>());
}catch (Exception e){
throw new RuntimeException("读取title_scheme表失败");
}
return List.of(new TitleScheme(null,"请你学习以下标题风格并对这种风格做出总结。命名为风格A\n" +
"标题一:姿态被搞到破防崩溃,上演大型红温现场,这次生气不像演的感觉要掉小珍珠了!\n" +
"标题二:PDD节食减肥高光时刻回顾饭后猛炫6只去皮鸡腿 \n" +
"标题三:BLG击败FNC外战一把不输外战幻神BLG武器神Bin天降晕四个斩获三杀 \n" +
"标题四:前有TheShy天神下凡一锤四今有刚神下凡一斩四海龟剑姬jjking荣归故里吊打小代\n" +
"标题五:属于男生的综艺来了!姿态最新惩罚局,一手辅助维克托上演“超鬼”"
public List<?> sqlInit() {
return List.of(new TitleScheme(null,"标题一:主播被搞到破防崩溃,上演大型红温现场,这次生气不像演的感觉要掉小珍珠了!\\n标题二:主播节食减肥高光时刻回顾饭后猛炫6只去皮鸡腿 \\n标题三:BLG击败FNC外战一把不输外战幻神BLG武器神Bin天降晕四个斩获三杀 \\n标题四:前有TheShy天神下凡一锤四今有刚神下凡一斩四海龟剑姬jjking荣归故里吊打小代\\n标题五:属于男生的综艺来了!姿态最新惩罚局,一手辅助维克托上演“超鬼”。请你学习以上标题样例总结出一种风格,我接下来为您提供的主播名称,弹幕内容,直播内容,标签等信息,请你作为一个热门短视频博主,根据你总结的风格和我提供的信息来生成一个吸引眼球,爆火,符合当今流行梗的短视频标题。注意:只需要给我标题,不需要“标题:”等任何前缀词语。你的所有数据信息应该从我为你提供的信息中获取,不要从标题样例中获取任何数据信息。"
,"global"));
}
}

View File

@@ -0,0 +1,57 @@
package org.example.core.auto.video.title;
import com.alibaba.fastjson.JSONObject;
import org.example.bean.section.PackageSection;
import org.example.bean.section.VideoSection;
import org.example.constpool.PluginName;
import org.example.core.gpt.ChatGPTMsgBuilder;
import org.example.core.gpt.OpenAPIPlugin;
import org.example.plugin.PluginCheckAndDo;
import org.example.pojo.GPTKey;
import org.example.pojo.TitleScheme;
import org.example.util.ClassUtil;
import org.example.util.MapUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* @author Genius
* @date 2023/10/25 20:17
**/
@Component
public class RandomTitleGenerator extends TitleGenerator{
@Override
public List<?> sqlInit() {
return null;
}
@Override
public void preGenerate() {
}
@Override
public String generate(Map<String, Object> data) {
try {
Object barrages = data.get("barrages");
Object labels = data.get("labels");
if(barrages instanceof List){
String barrage = ((List<?>) barrages).get((int) (Math.random() * ((List) barrages).size())).toString();
String liver = MapUtil.getString(data,"liver");
String tag = MapUtil.getString(data,"tag");
String label = "";
if(labels instanceof List){
label = ((List<?>) labels).get((int) (Math.random() * ((List) labels).size())).toString();
}
return String.format("【%s】%s%s直播弹幕直呼:%s!!",tag,liver,label,barrage);
}
} catch (Exception e){
return "";
}
return "";
}
}

View File

@@ -1,28 +1,37 @@
package org.example.core.auto.video.title;
import org.example.core.auto.AutoGenerator;
import org.example.bean.section.PackageSection;
import org.example.bean.section.VideoSection;
import org.example.core.auto.AbstractGeneratePlugin;
import org.example.core.auto.SectionPipeline;
import org.example.core.auto.video.description.DescGenerator;
import org.example.plugin.SpringBootPlugin;
import org.example.util.StringUtil;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author Genius
* @date 2023/10/22 17:53
**/
@Component
public class TitleGeneratePlugin extends SpringBootPlugin {
private TitleGenerator autoGenerator;
public class TitleGeneratePlugin extends AbstractGeneratePlugin<TitleGenerator> {
@Resource
Map<String, TitleGenerator> titleGeneratorMap;
@Override
public boolean init() {
this.generatorMap = titleGeneratorMap;
this.type = StringUtil.lowerCaseFirstLetter(GptTitleGenerator.class.getSimpleName());
return super.init();
}
public String generate(Object data) {
autoGenerator.preGenerate();
return autoGenerator.generate(data);
}
}

View File

@@ -1,8 +1,29 @@
package org.example.core.auto.video.title;
import org.example.bean.section.PackageSection;
import org.example.bean.section.VideoSection;
import org.example.core.auto.AutoGenerator;
import org.example.core.auto.SectionGenerator;
import org.example.sql.SQLInitMachine;
import org.example.sql.annotation.SQLInit;
import org.example.util.ClassUtil;
import org.springframework.beans.BeanUtils;
public interface TitleGenerator extends AutoGenerator<String> {
import java.util.Map;
Object preGenerate();
public abstract class TitleGenerator extends SectionGenerator<String> {
@Override
public <T extends VideoSection, V extends VideoSection> V generator(T section) {
PackageSection packageSection = new PackageSection();
BeanUtils.copyProperties(section,packageSection);
try {
Map<String, Object> map = ClassUtil.toDeepMap(packageSection);
String title = this.generate(map);
packageSection.setTitle(title);
}catch (Exception e){
return (V) section;
}
return (V) packageSection;
}
}

View File

@@ -0,0 +1,25 @@
package org.example.init;
import org.example.constpool.ModuleName;
import org.example.constpool.PluginName;
import org.example.core.auto.video.description.DescGeneratorPlugin;
import org.example.core.auto.video.title.TitleGeneratePlugin;
import org.example.plugin.annotation.Plugin;
import org.springframework.stereotype.Component;
/**
* @author Genius
* @date 2023/10/25 21:26
**/
@Plugin(moduleName = ModuleName.SECTION_WORK,
pluginName = PluginName.DESC_GENERATE,
pluginName_CN = "标题生成插件",
pluginDescription = "根据切片内容自动生成切片标题",
pluginClass= DescGeneratorPlugin.class,
springBootPlugin = true,
ignore=true
)
@Component
public class DescGeneratorPluginInitMachine extends SpringPlugInitMachine{
}

View File

@@ -0,0 +1,24 @@
package org.example.init;
import org.example.constpool.ModuleName;
import org.example.constpool.PluginName;
import org.example.core.analysis.EmotionAnalysisPlugin;
import org.example.core.auto.video.title.TitleGeneratePlugin;
import org.example.plugin.annotation.Plugin;
import org.springframework.stereotype.Component;
/**
* @author Genius
* @date 2023/10/25 19:28
**/
@Plugin(moduleName = ModuleName.SECTION_WORK,
pluginName = PluginName.TITLE_GENERATE,
pluginName_CN = "标题生成插件",
pluginDescription = "根据切片内容自动生成切片标题",
pluginClass= TitleGeneratePlugin.class,
springBootPlugin = true,
ignore=true
)
@Component
public class TitleGeneratePluginInitMachine extends SpringPlugInitMachine{
}

View File

@@ -0,0 +1,7 @@
package org.example.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.example.pojo.DescScheme;
public interface DescSchemeMapper extends BaseMapper<DescScheme> {
}

View File

@@ -0,0 +1,23 @@
package org.example.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author Genius
* @date 2023/10/25 21:07
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("desc_scheme")
public class DescScheme {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String system;
private String type;
}

View File

@@ -1,11 +1,40 @@
package org.example.core.section;
import org.example.bean.Barrage;
import org.example.bean.section.VideoSection;
import org.example.constpool.ConstPool;
import org.example.constpool.GlobalFileCache;
import org.example.mapper.VideoSectionMapper;
import org.example.util.JsonFileUtil;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* @author Genius
* @date 2023/10/22 20:56
**/
@Component
public class SectionParking {
@Resource
VideoSectionMapper mapper;
private void saveData(VideoSection section){
String root = (String) GlobalFileCache.ModuleSrcConfigFile.get("src", ConstPool.BARRAGE);
String liveRoot = (String)GlobalFileCache.ModuleSrcConfigFile.get("src", ConstPool.LIVE_RECORD);
String path = section.getVideoPath().replace(liveRoot,root);
if (JsonFileUtil.writeJsonFile(path, Map.of("data",section.getBarrages())).isFile()) {
section.setBarrageFile(path);
}
}
public void parking(VideoSection section){
saveData(section);
mapper.insert(section);
}
}

View File

@@ -1,18 +1,19 @@
package org.example.core.section;
import org.apache.coyote.Request;
import org.example.bean.Live;
import org.example.cache.FileCache;
import org.example.bean.section.VideoSection;
import org.example.constpool.ConstPool;
import org.example.constpool.FileNameBuilder;
import org.example.constpool.GlobalFileCache;
import org.example.plugin.SpringGuardPlugin;
import org.example.sql.annotation.SQLInit;
import org.example.util.ExceptionUtil;
import org.example.util.FileUtil;
import org.example.util.TimeUtil;
import org.example.util.VideoUtil;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.nio.file.Paths;
import java.util.List;
import java.util.concurrent.BlockingQueue;
@@ -30,6 +31,9 @@ public class VideoSectionWorkShop extends SpringGuardPlugin {
private String liveRoot;
@Resource
SectionParking sectionParking;
@Override
public boolean init() {
requests = new LinkedBlockingQueue<>(1000);
@@ -41,12 +45,23 @@ public class VideoSectionWorkShop extends SpringGuardPlugin {
public void start() {
try {
SectionRequest request = requests.poll(1000, TimeUnit.SECONDS);
VideoSection videoSection = generateSection(request);
sectionParking.parking(videoSection);
}catch (InterruptedException e){
return;
}catch (Exception e){
e.printStackTrace();
}
}
private VideoSection generateSection(SectionRequest request){
try {
if(request!=null){
long videoStartTime = TimeUtil.getTimeNaos(request.getDate());
long start = (timeBias(request.getStartTime())-videoStartTime)/1000;
start = start<0?0:start;
long end = (timeBias(request.getEndTime())-videoStartTime)/1000;
List<String> barrages = request.getBarrages();
String root = Paths.get(liveRoot,request.getAction(),request.getPlatform()).toString();
String startTime = VideoUtil.formatTimeToFFMpeg(start);
String endTime = VideoUtil.formatTimeToFFMpeg(end);
@@ -59,14 +74,15 @@ public class VideoSectionWorkShop extends SpringGuardPlugin {
String newPath = Paths.get(root,newVideoName).toString();
if (VideoUtil.cutVideoByFFMpeg(oldPath,newPath,startTime,endTime)) {
this.info("切片生成", String.format("产生切片文件%s 主播:%s", newVideoName,liver),true);
VideoSection videoSection = new VideoSection(newVideoName,request.getTag(),request.getLiver(),request.getPlatform());
VideoSection videoSection = new VideoSection(newVideoName, request.getTag(), request.getLiver(), request.getPlatform());
videoSection.setBarrages(barrages);
return videoSection;
}
}
}catch (InterruptedException e){
return;
}catch (Exception e){
e.printStackTrace();
this.error("切片生成失败", String.format("切片生成失败,原因:%s", ExceptionUtil.getCause(e)),true);
}
return null;
}
public long timeBias(long time){
return time+8*1000;
@@ -89,12 +105,12 @@ public class VideoSectionWorkShop extends SpringGuardPlugin {
"\t\"id\"\tINTEGER NOT NULL,\n" +
"\t\"video_name\"\tTEXT NOT NULL,\n" +
"\t\"liver\"\tTEXT NOT NULL,\n" +
"\t\"barrages\"\tTEXT NOT NULL,\n" +
"\t\"barrage_file\"\tTEXT NOT NULL,\n" +
"\t\"tag\"\tTEXT NOT NULL,\n" +
"\t\"date\"\tTEXT NOT NULL,\n" +
"\t\"platform\"\tTEXT,\n" +
"\tPRIMARY KEY(\"id\" AUTOINCREMENT)\n" +
")")
");")
public List<?> sqlInit() {
return null;
}

View File

@@ -0,0 +1,7 @@
package org.example.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.example.bean.section.VideoSection;
public interface VideoSectionMapper extends BaseMapper<VideoSection> {
}

View File

@@ -3,12 +3,16 @@ package org.example.sectionwork;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.example.ConsoleApplication;
import org.example.bean.section.VideoSection;
import org.example.core.auto.video.description.DescGeneratorPlugin;
import org.example.core.auto.video.title.TitleGeneratePlugin;
import org.example.util.JsonFileUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -21,6 +25,11 @@ import java.util.stream.Collectors;
@SpringBootTest(classes = ConsoleApplication.class,webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class TitleGenerateTest {
@Resource
TitleGeneratePlugin plugin;
@Resource
DescGeneratorPlugin descGeneratorPlugin;
@Test
public void test(){
Map<String, Object> map = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\config\\Barrage\\online\\huya\\Uzi_2023-10-18 21_22_57.json");
@@ -32,7 +41,14 @@ public class TitleGenerateTest {
}
return "";
}).collect(Collectors.toList());
System.out.println(content);
VideoSection videoSection = new VideoSection();
videoSection.setBarrages(content.subList(0,100));
videoSection.setTag("英雄联盟");
videoSection.setLiver("UZI");
VideoSection process = plugin.process(videoSection);
System.out.println(process);
VideoSection process1 = descGeneratorPlugin.process(process);
System.out.println(process1);
}
}
}

View File

@@ -22,9 +22,10 @@ public class VoiceToTextTest {
public static final MediaType MEDIA_TYPE_WAV = MediaType.parse("audio/wav");
public static void main(String... args) throws IOException {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 7890));
OkHttpClient client = new OkHttpClient.Builder().proxy(proxy).connectTimeout(60, TimeUnit.SECONDS).build();
// Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 7890));
OkHttpClient client = new OkHttpClient.Builder().connectTimeout(120, TimeUnit.SECONDS).readTimeout(120,TimeUnit.SECONDS).writeTimeout(60,TimeUnit.SECONDS).build();
long l = System.currentTimeMillis();
// 音频文件
File audioFile = new File("E:\\Project\\chopperbot-1.0\\audioTest.mp3");
@@ -39,8 +40,10 @@ public class VoiceToTextTest {
// 请求
Request request = new Request.Builder()
.addHeader("Authorization", "Bearer " + "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")
.url("https://api.openai.com/v1/audio/transcriptions")
.addHeader("Authorization", "Bearer " + "sk-xgUDtOdRgQLigz2D0e4cA665441e4287AfCf8458B1C21b0f")
// .url("https://api.openai.com/v1/audio/transcriptions")
//.url("https://oneapi.a9.gay/v1/audio/transcriptions")
.url(" https://oneapi.a9.gay/openai/deployments/whisper-1/audio/transcriptions?api-version=2023-09-01-preview")
.post(requestBody)
.build();
@@ -49,6 +52,7 @@ public class VoiceToTextTest {
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
System.out.println(response.body().string());
System.out.println((System.currentTimeMillis() - l)/1000);
}
}

View File

@@ -38,5 +38,5 @@
"OpenAPI":true
}
},
"updateTime":"2023-10-23 15:10:01"
"updateTime":"2023-10-25 15:01:54"
}

View File

@@ -0,0 +1,26 @@
import request from "@/utils/request";
import { Label } from "@/views/app/label/LabelTypes";
export function list() {
return request({
url: "/account/label/list/",
method: "get",
});
}
export function add(label: string) {
return request.post("/account/label/add/", { label: label });
}
export function remove(label: string) {
return request({
url: "/account/label/delete/",
method: "get",
params: {
label: label,
},
});
}
export function update(Label: Label) {
return request.post("/account/label/update/", Label);
}

View File

@@ -1,7 +1,8 @@
<script setup lang="ts">
import { useCustomizeThemeStore } from "@/stores/customizeTheme";
import { usePluginStore } from "@/views/setting/plugin/pluginStore";
const pluginStore = usePluginStore();
const customizeTheme = useCustomizeThemeStore();
const props = defineProps({
// Data
menu: {
@@ -10,7 +11,20 @@ const props = defineProps({
},
});
onMounted(() => {});
onMounted(async () => {
await pluginStore.initList;
console.log(pluginStore.pluginList);
});
const isRegister = (item: any) => {
if (item?.plugin) {
const plugin = pluginStore.pluginList.find(
(plugin) => plugin.pluginName === item.plugin
);
return plugin && plugin.register;
}
return true;
};
</script>
<template>
<v-list nav dense color="primary">
@@ -25,7 +39,7 @@ onMounted(() => {});
<template v-for="menuItem in menuArea.items" :key="menuItem.key">
<!-- menu level 1 -->
<v-list-item
v-if="!menuItem.items"
v-if="!menuItem.items && isRegister(menuItem)"
:to="menuItem.link"
:prepend-icon="menuItem.icon || 'mdi-circle-medium'"
:active-class="`active-nav-${customizeTheme.primaryColor.colorName}`"
@@ -35,7 +49,10 @@ onMounted(() => {});
v-text="menuItem.key ? $t(menuItem.key) : menuItem.text"
></v-list-item-title>
</v-list-item>
<v-list-group v-else :value="menuItem.items">
<v-list-group
v-else-if="isRegister(menuItem)"
:value="menuItem.items"
>
<!-- subMenu activator -->
<template v-slot:activator="{ props }">
<v-list-item

View File

@@ -12,7 +12,7 @@ const customizeTheme = useCustomizeThemeStore();
const navigation = ref(configs.navigation);
const openGithubSite = () => {
window.open("https://github.com/969025903/ChopperBot", "_blank");
window.open("https://github.com/Geniusay/ChopperBot", "_blank");
};
</script>

View File

@@ -6,40 +6,53 @@ export default [
link: "/apps/board",
},
{
icon:"mdi mdi-ladybug",
key:"menu.creeper_library",
text:"Creeper Library",
link: "/apps/creeperLibrary"
icon: "mdi mdi-ladybug",
key: "menu.creeper_library",
text: "Creeper Library",
link: "/apps/creeperLibrary",
plugin: "CreeperManager",
},
{
icon:"mdi mdi-account-hard-hat-outline",
key:"menu.task_center",
text:"Task Center",
link: "/apps/taskCenter"
icon: "mdi mdi-account-hard-hat-outline",
key: "menu.task_center",
text: "Task Center",
link: "/apps/taskCenter",
plugin: "TaskCenter",
},
{
icon:"mdi mdi-monitor-cellphone-star",
key:"menu.hot_guard",
text:"Hot Guard",
link: "/apps/hotGuard"
icon: "mdi mdi-monitor-cellphone-star",
key: "menu.hot_guard",
text: "Hot Guard",
link: "/apps/hotGuard",
plugin: "HotGuard",
},
{
icon:"mdi mdi-bird",
key:"menu.heat_recommend",
text:"Heat Recommend",
link: "/apps/heatRecommend"
icon: "mdi mdi-bird",
key: "menu.heat_recommend",
text: "Heat Recommend",
link: "/apps/heatRecommend",
plugin: "HotRecommendation",
},
{
icon:"mdi mdi-star-face",
key:"menu.live_follow",
text:"Live Follow",
link: "/apps/liveFollow"
icon: "mdi mdi-star-face",
key: "menu.live_follow",
text: "Live Follow",
link: "/apps/liveFollow",
plugin: "LiverFollower",
},
{
icon:"mdi mdi-chart-line",
key:"menu.barrage_curve",
text:"Barrage Curve",
link: "/apps/barrageCurve"
icon: "mdi mdi-chart-line",
key: "menu.barrage_curve",
text: "Barrage Curve",
link: "/apps/barrageCurve",
plugin: "BarrageScoreCurve",
},
{
icon: "mdi mdi-tag-faces",
key: "menu.label",
text: "Label Manage",
link: "/apps/label",
plugin: "LabelManager",
},
{
icon: "mdi-forum-outline",

View File

@@ -49,7 +49,7 @@ export default {
unsplash: "Unsplash",
booking: "Booking",
ikea: "IKEA",
label:"Label Manager",
board: "Task Board",
users: "Users",

View File

@@ -123,7 +123,8 @@ export default {
heat_recommend:"热门直播推荐",
live_follow:"关注主播",
barrage_curve:"弹幕得分曲线",
hot_live:"热门直播"
hot_live:"热门直播",
label:"标签管理"
},
dashboard: {
activity: "活动",

View File

@@ -120,6 +120,20 @@ export default [
category: "APP",
},
},
{
path: "/apps/label",
name: "app-label-manage",
component: () =>
import(
/* webpackChunkName: "utility-board" */ "@/views/app/label/LabelManageView.vue"
),
meta: {
requiresAuth: true,
title: "Label Manage",
layout: "ui",
category: "APP",
},
},
{
path: "/apps/nitori",
meta: {

View File

@@ -1,47 +1,51 @@
import axios from "axios";
import {useSnackbarStore} from "@/stores/snackbarStore";
import { useSnackbarStore } from "@/stores/snackbarStore";
const snackbarStore = useSnackbarStore();
const request = axios.create({
baseURL: "/appApi",
timeout: 100000,
});
request.interceptors.request.use(config => {
//config.headers['Content-Type'] = 'application/json';
return config
}, error => {
return Promise.reject(error)
});
request.interceptors.request.use(
(config) => {
//config.headers['Content-Type'] = 'application/json';
return config;
},
(error) => {
return Promise.reject(error);
}
);
// response 拦截器
// 可以在接口响应后统一处理结果
request.interceptors.response.use(
response => {
if(response.status!=200){
snackbarStore.showSuccessMessage("服务异常!")
(response) => {
const snackbarStore = useSnackbarStore();
if (response.status != 200) {
snackbarStore.showSuccessMessage("服务异常!");
}
let res = response.data;
if(res.code === 114514){
snackbarStore.showErrorMessage("该插件没有启动,请先启动插件!")
if (res.code === 114514) {
snackbarStore.showErrorMessage(res.msg);
}
// 如果是返回的文件
if (response.config.responseType === 'blob') {
return res
if (response.config.responseType === "blob") {
return res;
}
// 兼容服务端返回的字符串数据
if (typeof res === 'string') {
res = res ? JSON.parse(res) : res
if (typeof res === "string") {
res = res ? JSON.parse(res) : res;
}
return res;
},
error => {
console.log('err' + error) // for debug
(error) => {
const snackbarStore = useSnackbarStore();
snackbarStore.showErrorMessage("操作异常!");
console.log("err" + error); // for debug
// localStorage.removeItem('token')
//router.replace({path:'/login'})
return Promise.reject(error)
return Promise.reject(error);
}
)
);
export default request
export default request;

View File

@@ -8,3 +8,8 @@ export const timeRules = [
(v)=> v > 0 || "时间必须大于0",
(v)=> v >= 1000 || "时间必须大于1s",
]
export const validate = (rules: [], data: any) =>{
return rules.some((rule) => typeof rule(data) === "string")
}

View File

@@ -18,7 +18,6 @@ const headers = [
{ text: "操作", value: "option" },
];
const open = (item) => {};
const follows = ref<FocusLiver[]>([])
follows.value = liveFollowStore.liveFollowList
@@ -32,7 +31,6 @@ onMounted(async () => {
}, 1000);
});
const keys = ["group","name"]
const deleteLive = async (item) =>{
await unFollow(item.platform,item.liver).then(res=>{
if(res?.data?.success){

View File

@@ -0,0 +1,126 @@
<template>
<v-card>
<v-card-title class="font-weight-bold">
<span>Label Manage</span>
<v-spacer></v-spacer>
<v-text-field
@keyup.enter="addLabel()"
v-model="input"
:loading="loading"
append-inner-icon="mdi-map-marker"
label="输入要添加的标签"
:rules="strRules"
></v-text-field>
</v-card-title>
<div>
<v-chip
v-for="(item, index) in labelManageStore.labels"
:color="chooseColor(index)"
class="ma-2 pa-2"
closable
@click="openUpdateDialog(item)"
@click:close="removeLabel(item.label)"
>
{{ item.label }}
</v-chip>
</div>
</v-card>
<v-dialog v-model="dialog" persistent width="1024">
<v-card>
<v-card-title>
<span class="text-h5">更新Label</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col cols="12">
<v-text-field
v-model="update.label"
label="更新Label"
:rules="strRules"
required
></v-text-field>
</v-col>
</v-row>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue-darken-1" variant="text" @click="dialog = false">
Close
</v-btn>
<v-btn
color="blue-darken-1"
variant="text"
@click="updateLabel()"
:disabled="validate(strRules, update)"
>
Save
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script setup lang="ts">
import { list } from "@/api/account/labelApi";
import { useLabelManageStore } from "@/views/app/label/LabelManagerStore";
import { strRules, validate } from "~/src/utils/validate";
import { useSnackbarStore } from "~/src/stores/snackbarStore";
import { Label } from "@/views/app/label/LabelTypes";
const labelManageStore = useLabelManageStore();
const snackbarStore = useSnackbarStore();
const input = ref("");
const update = ref<Label>();
const loading = ref(false);
const dialog = ref(false);
const colorGroup = [
"blue",
"secondary",
"orange",
"pink",
"red",
"yellow",
"green",
];
onMounted(async () => {
await list().then((res) => {
labelManageStore.labels = res.data.list;
});
});
const chooseColor = (index: number) => {
return colorGroup[index % colorGroup.length];
};
const addLabel = async () => {
if (strRules.some((rule) => typeof rule(input.value) === "string")) {
snackbarStore.showErrorMessage("输入不能为空");
return;
} else {
loading.value = true;
labelManageStore.addLabel(input.value);
input.value = "";
loading.value = false;
}
};
const removeLabel = async (label) => {
await labelManageStore.removeLabel(label);
};
const openUpdateDialog = (label: Label) => {
update.value = label;
dialog.value = true;
};
const updateLabel = async () => {
await labelManageStore.updateLabel(update.value);
dialog.value = false;
};
</script>
<style scoped>
.labels {
display: flex;
flex-direction: row;
}
</style>

View File

@@ -0,0 +1,48 @@
import { defineStore } from "pinia";
import { useSnackbarStore } from "~/src/stores/snackbarStore";
import { add, remove, update } from "@/api/account/labelApi";
import { Label } from "@/views/app/label/LabelTypes"
const snackbarStore = useSnackbarStore();
export const useLabelManageStore = defineStore({
id: "labelManage",
state: () => ({
labels: ref<Label[]>([]),
}),
getters: {},
actions: {
async removeLabel(label: string) {
await remove(label).then((res) => {
if (res?.data?.success) {
this.labels = this.labels.filter((item) => item.label !== label);
snackbarStore.showSuccessMessage("删除成功");
} else {
snackbarStore.showErrorMessage("删除失败");
}
});
},
async addLabel(label: string) {
await add(label).then((res) => {
if (res.code===200) {
snackbarStore.showSuccessMessage("添加成功");
this.labels.push(res.data.data as Label);
} else {
snackbarStore.showErrorMessage("添加失败");
}
});
},
async updateLabel(label: Label) {
await update(label).then((res) => {
if (res?.data?.success) {
snackbarStore.showSuccessMessage("更新成功");
const index = this.labels.findIndex((item) => item.label === label.label);
this.labels[index].label = label.label;
} else {
snackbarStore.showErrorMessage("更新失败");
}
});
},
},
});

View File

@@ -0,0 +1,5 @@
export interface Label{
id: number;
labelId: string;
label: string;
}

View File

@@ -1,9 +1,9 @@
import { defineStore } from "pinia";
import { Plugin } from "./pluginTypes"
import {startPlugin, closePlugin, enablePlugin, disabledPlugin} from "@/api/pluginApi";
import {startPlugin, closePlugin, enablePlugin, disabledPlugin, allPlugins} from "@/api/pluginApi";
import { useSnackbarStore } from "@/stores/snackbarStore";
const snackbarStore = useSnackbarStore();
export const usePluginStore = defineStore({
id: "plugin",
@@ -35,6 +35,12 @@ export const usePluginStore = defineStore({
}),
getters:{
async initList(){
await allPlugins().then(res=>{
this.pluginList = res.data
})
return this.pluginList
},
getAllList(){
return this.pluginList
},
@@ -65,7 +71,8 @@ export const usePluginStore = defineStore({
actions:{
startPlugin(plugin: Plugin){
startPlugin(plugin.pluginName).then(res => {
startPlugin(plugin.pluginName).then(res => {
const snackbarStore = useSnackbarStore();
// @ts-ignore
if(res.code===200){
plugin.register = true
@@ -81,6 +88,7 @@ export const usePluginStore = defineStore({
closePlugin(plugin: Plugin){
closePlugin(plugin.pluginName).then(res => {
const snackbarStore = useSnackbarStore();
// @ts-ignore
if(res.code===200){
plugin.register = false
@@ -96,6 +104,7 @@ export const usePluginStore = defineStore({
enablePlugin(plugin: Plugin){
enablePlugin(plugin.pluginName).then(res => {
const snackbarStore = useSnackbarStore();
// @ts-ignore
if(res.code === 200 && res.data.success === true){
plugin.start = true
@@ -110,6 +119,7 @@ export const usePluginStore = defineStore({
disabledPlugin(plugin: Plugin){
disabledPlugin(plugin.pluginName).then(res => {
const snackbarStore = useSnackbarStore();
// @ts-ignore
if(res.code === 200 && res.data.success === true){
plugin.start = false

View File

@@ -16,6 +16,6 @@ git commit -m 'deploy'
# 推到你仓库的的 gh-page 分支
# 将 <USERNAME>/<REPO> 替换为你的信息
git push -f git@github.com:969025903/ChopperBot-Doc.git master:gh-pages
git push -f git@github.com:Geniusay/ChopperBot-Doc.git master:gh-pages
```

View File

@@ -23,5 +23,5 @@ module.exports = [
text: "🚀起飞诶~~起飞",
link: "/pages/1fedc1/",
},
{ text: "更新日志", link: "https://github.com/969025903/ChopperBot/blob/master/CHANGELOG.md" },
{ text: "更新日志", link: "https://github.com/Geniusay/ChopperBot/blob/master/CHANGELOG.md" },
];

View File

@@ -6,11 +6,11 @@ module.exports = {
nav,
sidebarDepth: 2,
logo: "/img/logo.svg",
repo: "969025903/ChopperBot",
repo: "Geniusay/ChopperBot",
searchMaxSuggestions: 10,
lastUpdated: "上次更新",
docsRepo: "/969025903/Chopper-Doc",
docsRepo: "/Geniusay/Chopper-Doc",
docsDir: "docs",
docsBranch: "master",
editLinks: true,
@@ -29,7 +29,7 @@ module.exports = {
author: {
name: "Genius",
href: "https://github.com/969025903"
href: "https://github.com/Geniusay"
},
social: {
@@ -37,7 +37,7 @@ module.exports = {
{
iconClass: "icon-github",
title: "GitHub",
link: "https://github.com/969025903"
link: "https://github.com/Geniusay"
},
{
iconClass: "icon-gitee",
@@ -55,13 +55,13 @@ module.exports = {
footer: {
createYear: 2016,
copyrightInfo: [
'<a href="https://969025903.github.io/" target="_blank" style="font-weight:bold">TimeMachine Lab</a>',
'<a href="https://Geniusay.github.io/" target="_blank" style="font-weight:bold">TimeMachine Lab</a>',
' | ',
'Sponsored by <a href="https://www.jetbrains.com" target="_blank" style="font-weight:bold">JetBrains</a>',
' | ',
'<a href="http://beian.miit.gov.cn/" target=_blank>渝ICP备2021000141号-1</a>',
'<p>友情链接:',
'<a href="https://969025903.github.io/" target="_blank" style="font-weight:bold">GeniusBlog</a>',
'<a href="https://Geniusay.github.io/" target="_blank" style="font-weight:bold">GeniusBlog</a>',
'</p>'
].join('')
},

View File

@@ -34,7 +34,7 @@ ChopperBot将会创建 **./config根目录**,并在其中安装所有模块的
频繁大量的IO流会使项目性能降低针对ChopperBot的文件操作我们专门使用了文件缓存技术来实现项目对文件快速的响应。
## ChopperBot的启动过程
**代码请见** [InitWorld](https://github.com/969025903/ChopperBot/blob/master/common/src/main/java/org/example/init/InitMachine.java) 👈
**代码请见** [InitWorld](https://github.com/Geniusay/ChopperBot/blob/master/common/src/main/java/org/example/init/InitMachine.java) 👈
![image](https://mynoteimages.oss-cn-hangzhou.aliyuncs.com/20230802232256636.png)
## 项目文件层级关系

View File

@@ -10,7 +10,7 @@ article: false
## TML研究所其余作品
- [UltimateCache](https://gitee.com/welsir/ultimate-cache) - 致力于开发一个能够用于实际生产的redis注解缓存(开发中)。
- [Assistant](https://gitee.com/969025903/Assistant) - 致力于开发一个后端开发的百宝箱。
- [Assistant](https://gitee.com/Geniusay/Assistant) - 致力于开发一个后端开发的百宝箱。
## 更多优秀开源作品

View File

@@ -11,7 +11,7 @@ editLink: false
如果您正在使用这个项目并感觉良好,或者是想支持我们继续开发,您可以通过如下`任意`方式支持我们:
1. Star 并向您的朋友推荐或分享 [ChopperBot](https://github.com/969025903/ChopperBot) 🚀
1. Star 并向您的朋友推荐或分享 [ChopperBot](https://github.com/Geniusay/ChopperBot) 🚀
2. 轻轻点击一次页面右下角(ad) 🙃
3. 通过以下二维码进行一次性捐款,请我喝一杯可乐 🥤
@@ -31,12 +31,12 @@ editLink: false
相关联系方式(添加烦请注明来意):
- QQ[969025903](tencent://message/?uin=969025903&Site=&Menu=yes)
- QQ[Geniusay](tencent://message/?uin=Geniusay&Site=&Menu=yes)
- QQ[燧枫](tencent://message/?uin=369202865&Site=&Menu=yes)
- QQ[Weisir](tencent://message/?uin=1824379011&Site=&Menu=yes)
- QQ[脑洞大开](tencent://message/?uin=647831033&Site=&Menu=yes)
- 邮件:[geniusssbg@gmail.com](mailto:geniusssbg@gmail.com)
- Github[https://github.com/969025903/ChopperBot](https://github.com/969025903/ChopperBot)
- Github[https://github.com/Geniusay/ChopperBot](https://github.com/Geniusay/ChopperBot)
## 致谢

View File

@@ -5,7 +5,7 @@ permalink: /pages/24112f/
article: false
---
[ChopperBot](https://github.com/969025903/ChopperBot) 一款全自动的主播切片机器人,支持模块热度分析, 主播热度分析,智能爬取,弹幕视频爬取,弹幕分析, 自动切片,切片分类,自动标题,自动封面,账号打造,账号管理, 多平台上传等功能
[ChopperBot](https://github.com/Geniusay/ChopperBot) 一款全自动的主播切片机器人,支持模块热度分析, 主播热度分析,智能爬取,弹幕视频爬取,弹幕分析, 自动切片,切片分类,自动标题,自动封面,账号打造,账号管理, 多平台上传等功能
::: tip 愿景
ChopperBot 留下每个主播的精彩片段
:::
@@ -29,12 +29,12 @@ ChopperBot 留下每个主播的精彩片段
## 代码托管
> **[Gitee](https://gitee.com/sbg-genius/ChopperBot)** | **[Github](https://github.com/969025903/ChopperBot)**
> **[Gitee](https://gitee.com/sbg-genius/ChopperBot)** | **[Github](https://github.com/Geniusay/ChopperBot)**
## 参与贡献
欢迎各路大佬一起来参与完善 ChopperBot捏我们期待你的 PR
- 贡献代码:代码地址 [ChopperBot](https://github.com/969025903/ChopperBot) ,欢迎提交 Issue 或者 Pull Requests
- 维护文档:文档地址 [ChopperBot-Doc](https://github.com/969025903/ChopperBot-Doc) ,欢迎参与翻译和修订
- 贡献代码:代码地址 [ChopperBot](https://github.com/Geniusay/ChopperBot) ,欢迎提交 Issue 或者 Pull Requests
- 维护文档:文档地址 [ChopperBot-Doc](https://github.com/Geniusay/ChopperBot-Doc) ,欢迎参与翻译和修订

View File

@@ -4,7 +4,7 @@ date: 2023-05-19 02:09:32
permalink: /pages/e3a691/
---
[👉 源码](https://github.com/969025903/ChopperBot)
[👉 源码](https://github.com/Geniusay/ChopperBot)
[[toc]]

View File

@@ -5,7 +5,7 @@ permalink: /pages/779a6e/
article: false
---
[👉 源码](https://github.com/969025903/ChopperBot)
[👉 源码](https://github.com/Geniusay/ChopperBot)
[[toc]]
@@ -39,7 +39,7 @@ public void testDelete() throws IOException {
```
- `更多例子可查看test包下面的samples`
- [FileUtilTest](https://github.com/969025903/ChopperBot/blob/master/FileModule/src/test/java/org/example/util/FileUtilTest.java)
- [FileUtilTest](https://github.com/Geniusay/ChopperBot/blob/master/FileModule/src/test/java/org/example/util/FileUtilTest.java)
## JsonFileUtil
::: tip 说明
Json文件的操作工具类
@@ -77,4 +77,4 @@ public void writeClassInJsonFile() {
```
- `更多例子可查看test包下面的samples`
- [JsonFileUtilTest](https://github.com/969025903/ChopperBot/blob/master/FileModule/src/test/java/org/example/util/JsonFileUtilTest.java)
- [JsonFileUtilTest](https://github.com/Geniusay/ChopperBot/blob/master/FileModule/src/test/java/org/example/util/JsonFileUtilTest.java)

View File

@@ -128,4 +128,4 @@ ConfigFile的文件缓存池负责文件内容的缓存与刷入
### GlobalFileCache
- `更多例子可查看test包下面的samples`
- [FileCacheTest](https://github.com/969025903/ChopperBot/blob/master/FileModule/src/test/java/org/example/cache/FileCacheTest.java)
- [FileCacheTest](https://github.com/Geniusay/ChopperBot/blob/master/FileModule/src/test/java/org/example/cache/FileCacheTest.java)

View File

@@ -22,7 +22,7 @@ postList: none
<a class="become-sponsor" href="/pages/4fedc2">支持这个项目</a>
</p>
<p align="center">
<a class="become-sponsor" href="https://github.com/969025903/ChopperBot">这个项目还在开发中,请加入我们一起开发</a>
<a class="become-sponsor" href="https://github.com/Geniusay/ChopperBot">这个项目还在开发中,请加入我们一起开发</a>
</p>
<style>
.become-sponsor{
@@ -39,7 +39,7 @@ postList: none
### 🤡开发人员
[Genius🤡](https://github.com/969025903)
[Genius🤡](https://github.com/Geniusay)
[twj666🤡](https://github.com/tmlgenius)
[welsir🤡](https://github.com/tmlgenius)
[masteryf🤡](https://github.com/masteryf)
@@ -48,20 +48,20 @@ postList: none
### TML生态圈
- [ChopperBot](https://github.com/969025903/ChopperBot) - 一款后端开发小助手,快速生成代码,快速完成业务。
- [Assistant](https://github.com/969025903/Assistant) - 一款后端开发小助手,快速生成代码,快速完成业务。
- [ChopperBot](https://github.com/Geniusay/ChopperBot) - 一款后端开发小助手,快速生成代码,快速完成业务。
- [Assistant](https://github.com/Geniusay/Assistant) - 一款后端开发小助手,快速生成代码,快速完成业务。
### 代码托管
> **[Gitee](https://gitee.com/sbg-genius/ChopperBot)** | **[Github](https://github.com/969025903/ChopperBot)**
> **[Gitee](https://gitee.com/sbg-genius/ChopperBot)** | **[Github](https://github.com/Geniusay/ChopperBot)**
### 参与贡献
欢迎各路好汉一起来参与完善 ChopperBot我们期待你的 PR
- 贡献代码:代码地址 [ChopperBot](https://github.com/969025903/ChopperBot) ,欢迎提交 Issue 或者 Pull Requests
- 维护文档:文档地址 [ChopperBot-Doc](https://github.com/969025903/ChopperBot-Doc/) ,欢迎参与翻译和修订
- 贡献代码:代码地址 [ChopperBot](https://github.com/Geniusay/ChopperBot) ,欢迎提交 Issue 或者 Pull Requests
- 维护文档:文档地址 [ChopperBot-Doc](https://github.com/Geniusay/ChopperBot-Doc/) ,欢迎参与翻译和修订
### 友情链接
- [genius blog](https://969025903.github.io/)
- [genius blog](https://Geniusay.github.io/)