Skip to content

Commit

Permalink
2.6.4update
Browse files Browse the repository at this point in the history
  • Loading branch information
BanqiJane committed Apr 23, 2023
1 parent 89ba5ce commit 715e07d
Show file tree
Hide file tree
Showing 29 changed files with 592 additions and 315 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ java version "1.8.0_121"
</tbody>
</table>

# 版本2.6.3
# 版本2.6.4

- **danmuji(常规版本 需要java环境) [地址](https://github.com/BanqiJane/Bilibili_Danmuji/releases/tag/2.6.2 "下载地址")**<br/><br/>
- **danmuji(常规版本 需要java环境) [地址](https://github.com/BanqiJane/Bilibili_Danmuji/releases/tag/2.6.4 "下载地址")**<br/><br/>
- **danmuji-green(
window64绿色版本,不用配置安装java环境) [地址](https://github.com/BanqiJane/Bilibili_Danmuji/releases/tag/2.6.2 "下载地址")**<br/><br/>
window64绿色版本,不用配置安装java环境) [地址](https://github.com/BanqiJane/Bilibili_Danmuji/releases/tag/2.6.4 "下载地址")**<br/><br/>
- ~~**danmuji-docker(docker版本,由B站用户[西凉君君](https://live.bilibili.com/101937 "B站主页地址")提供
在此感谢) [地址](https://registry.hub.docker.com/r/xilianghe/danmuji "地址")**~~<br/><br/>
- **danmuji-docker(全框架docker镜像构建版本,由github用户[zzcabc](https://github.com/zzcabc "GitHub主页")提供
Expand Down Expand Up @@ -354,6 +354,17 @@ $ java -jar BiliBili_Danmuji-2.0beta.jar

<blockquote>
<blockquote>
<h2>Beta2.6.4</h2>
<p>更改部分文字提示</p>
<p>修复黑名单姬bug,黑名单姬添加全局包含模式</p>
<p>添加https至wss适应</p>
<p>增加web操作面板与弹幕姬版本检测</p>
<p>禁言窗口和禁言列表窗口修改为自适应,进一步适配手机端</p>
<p>导出设置json文件 添加时间戳命名</p>
<p>日志文件添加时间分割,错误日志现在不会启动清空了</p>
<p>修复部分已知bug</p>
</blockquote>
<blockquote>
<h2>Beta2.6.3</h2>
<p>新增黑名单姬</p>
<p>统一文件编码(utf8),更改文件权限</p>
Expand Down
19 changes: 11 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@ plugins {
id 'java'
}
group = 'xyz.acproject.danmuji'
version = '2.6.3beta'
version = '2.6.4beta'
sourceCompatibility = '1.8'
[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'

repositories {
mavenCentral()
maven{
name 'aliyunmaven'
url 'http://maven.aliyun.com/nexus/content/groups/public/'
url 'https://maven.aliyun.com/nexus/content/groups/public/'
}
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'org.springframework.boot:spring-boot-starter-undertow'
implementation ('org.springframework.boot:spring-boot-starter-web'){
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
implementation ('org.springframework.boot:spring-boot-starter-websocket'){
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-web'
}
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
Expand All @@ -37,12 +42,10 @@ dependencies {
implementation group: 'joda-time', name: 'joda-time', version: '2.10.5'
// https://mvnrepository.com/artifact/com.google.zxing/core
implementation group: 'com.google.zxing', name: 'core', version: '3.4.0'
// https://mvnrepository.com/artifact/net.glxn/qrgen
implementation group: 'net.glxn', name: 'qrgen', version: '1.4'
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.14.9'
// https://mvnrepository.com/artifact/commons-codec/commons-codec
implementation group: 'commons-codec', name: 'commons-codec', version: '1.14'
implementation group: 'commons-codec', name: 'commons-codec', version: '1.15'

implementation fileTree(dir: 'lib', includes: ['*.jar'])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ public class BlackParseComponent {
private static Logger LOGGER = LogManager.getLogger(BlackParseComponent.class);
public boolean autoReplay_parse(AutoReply autoReply) {
//全局开启
if (PublicDataConf.centerSetConf.getBlack().isAuto_reply()||PublicDataConf.centerSetConf.getBlack().isAll()) {
return this.parse(autoReply);
if(PublicDataConf.centerSetConf.getBlack()!=null) {
if (PublicDataConf.centerSetConf.getBlack().isAuto_reply() || PublicDataConf.centerSetConf.getBlack().isAll()) {
return this.parse(autoReply);
}
}else{
LOGGER.error("黑名单配置为空");
}
return true;
}
Expand All @@ -40,31 +44,42 @@ public boolean interact_parse(Interact interact) {
// } else if (interact.getMsg_type() == 2) {
//
// }
if (PublicDataConf.centerSetConf.getBlack().isThank_follow()||PublicDataConf.centerSetConf.getBlack().isThank_welcome()||PublicDataConf.centerSetConf.getBlack().isAll()) {
return this.parse(interact);
if(PublicDataConf.centerSetConf.getBlack()!=null) {
if (PublicDataConf.centerSetConf.getBlack().isThank_follow() || PublicDataConf.centerSetConf.getBlack().isThank_welcome() || PublicDataConf.centerSetConf.getBlack().isAll()) {
return this.parse(interact);
}
}else{
LOGGER.error("黑名单配置为空");
}
return true;
}

public boolean gift_parse(Gift gift) {
//全局开启
if (PublicDataConf.centerSetConf.getBlack().isThank_gift()||PublicDataConf.centerSetConf.getBlack().isAll()) {
return this.parse(gift);
if(PublicDataConf.centerSetConf.getBlack()!=null) {
if (PublicDataConf.centerSetConf.getBlack().isThank_gift() || PublicDataConf.centerSetConf.getBlack().isAll()) {
return this.parse(gift);
}
}else{
LOGGER.error("黑名单配置为空");
}
return true;
}


public <T> boolean global_parse(T t) {
//全局开启
if (PublicDataConf.centerSetConf.getBlack().isAll()) {
return this.parse(t);
if(PublicDataConf.centerSetConf.getBlack()!=null) {
if (PublicDataConf.centerSetConf.getBlack().isAll()) {
return this.parse(t);
}
}
return true;
}


public <T> boolean parse(T t) {
if(PublicDataConf.centerSetConf.getBlack()==null)return true;
boolean nameFlag = true;
boolean uidFlag = true;
//名称规则
Expand All @@ -78,32 +93,39 @@ public <T> boolean parse(T t) {
name = interact.getUname();
} else if (t instanceof Gift) { //感谢礼物
Gift gift = (Gift) t;
name = gift.getGiftName();
name = gift.getUname();
}
//判断
String replaced_s = s.replace("%", "");
if (s.startsWith("%") && s.endsWith("%")) {
if (StringUtils.contains(name, replaced_s)) {
nameFlag = false;
break;
//非模糊模式
if(!PublicDataConf.centerSetConf.getBlack().isFuzzy_query()) {
if (s.startsWith("%") && s.endsWith("%")) {
if (StringUtils.contains(name, replaced_s)) {
nameFlag = false;
break;
}
} else if (s.startsWith("%")) {
if (StringUtils.endsWith(name, replaced_s)) {
nameFlag = false;
break;
}
} else if (s.endsWith("%")) {
if (StringUtils.startsWith(name, replaced_s)) {
nameFlag = false;
break;
}
} else {
if (replaced_s.equals(name)) {
nameFlag = false;
break;
}
}
} else if (s.startsWith("%")) {
if (StringUtils.endsWith(name, replaced_s)) {
nameFlag = false;
break;
}
} else if (s.endsWith("%")) {
if (StringUtils.startsWith(name, replaced_s)) {
nameFlag = false;
break;
}
} else {
if (s.equals(name)) {
}else{
if(StringUtils.contains(name, replaced_s)){
nameFlag = false;
break;
}
}

}
String uid = "";
//uid规则
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/xyz/acproject/danmuji/conf/CenterSetConf.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ public class CenterSetConf implements Serializable {
private BlackListSetConf black;


@JSONField(name = "edition",serialize = false)
private String edition = "";



public CenterSetConf(ThankGiftSetConf thank_gift, AdvertSetConf advert,
ThankFollowSetConf follow, AutoReplySetConf reply, ClockInSetConf clock_in, ThankWelcomeSetConf welcome, AutoSendGiftConf auto_gift, PrivacySetConf privacy,BlackListSetConf black) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/xyz/acproject/danmuji/conf/PublicDataConf.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ public class PublicDataConf {
public static String SMALLHEART_ADRESS = null;
public static boolean is_sign= false;

public static String EDITION ="2.6.3";
public static String EDITION ="2.6.4";

public static String NEW_EDITION ="2.6.3";
public static String NEW_EDITION ="2.6.4";
public static String ANNOUNCE = null;
public static boolean INIT_CHECK_EDITION = false;
public static boolean INIT_CHECK_ANNOUNCE = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,22 @@ public class BlackListSetConf{
private boolean thank_follow;
@JSONField(name = "auto_reply")
private boolean auto_reply;
@JSONField(name = "fuzzy_query")
private boolean fuzzy_query;
@JSONField(name = "names")
private HashSet<String> names;
@JSONField(name = "uids")
private HashSet<String> uids;

public HashSet<String> getNames() {
if(names==null)return new HashSet<>();
return names;
}

public HashSet<String> getUids() {
if(uids!=null){
return uids.stream().sorted().collect(Collectors.toCollection(LinkedHashSet::new));
}
return uids;
return new HashSet<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ public HashSet<ThankGiftRuleSet> getThankGiftRuleSets() {
if(thankGiftRuleSets!=null) {
return thankGiftRuleSets.stream().sorted(Comparator.comparing(ThankGiftRuleSet::getGift_name)).collect(Collectors.toCollection(LinkedHashSet::new));
}
return thankGiftRuleSets;
return new HashSet<>();
}

public HashSet<String> getCodeStrings() {
if(codeStrings!=null) {
return codeStrings.stream().sorted().collect(Collectors.toCollection(LinkedHashSet::new));
}
return codeStrings;
return new HashSet<>();
}
}
25 changes: 13 additions & 12 deletions src/main/java/xyz/acproject/danmuji/config/DanmujiInitConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import xyz.acproject.danmuji.service.impl.SetServiceImpl;
import xyz.acproject.danmuji.tools.BASE64Encoder;

import java.util.Hashtable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* @author Jane
Expand All @@ -31,18 +32,18 @@ public class DanmujiInitConfig {
private SetServiceImpl checkService;

public void init(){
Hashtable<String, String> hashtable = new Hashtable<String, String>();
Map<String, String> profileMap = new ConcurrentHashMap<>();
String cookieString = null;
BASE64Encoder base64Encoder = new BASE64Encoder();
try {
hashtable.putAll(ProFileTools.read("DanmujiProfile"));
profileMap.putAll(ProFileTools.read("DanmujiProfile"));
} catch (Exception e) {
// TODO: handle exception
}
// 读取本地cookie
try {
cookieString = !StringUtils.isEmpty(hashtable.get(cookies))
? new String(base64Encoder.decode(hashtable.get(cookies)))
cookieString = !StringUtils.isEmpty(profileMap.get(cookies))
? new String(base64Encoder.decode(profileMap.get(cookies)))
: null;
} catch (Exception e) {
// TODO 自动生成的 catch 块
Expand All @@ -59,13 +60,13 @@ public void init(){
PublicDataConf.USERCOOKIE = null;
} else {
if (!StringUtils.isEmpty(PublicDataConf.USERCOOKIE)) {
hashtable.put(cookies, base64Encoder.encode(PublicDataConf.USERCOOKIE.getBytes()));
profileMap.put(cookies, base64Encoder.encode(PublicDataConf.USERCOOKIE.getBytes()));
}
}
// 读取本地set
try {
PublicDataConf.centerSetConf = !StringUtils.isEmpty(hashtable.get("set")) ? JSONObject
.parseObject(new String(base64Encoder.decode(hashtable.get("set"))), CenterSetConf.class) : null;
PublicDataConf.centerSetConf = !StringUtils.isEmpty(profileMap.get("set")) ? JSONObject
.parseObject(new String(base64Encoder.decode(profileMap.get("set"))), CenterSetConf.class) : null;
} catch (Exception e) {
// TODO: handle exception
LOGGER.error("读取配置文件失败,尝试重新读取" + e);
Expand Down Expand Up @@ -109,11 +110,11 @@ public void init(){
PublicDataConf.centerSetConf.setBlack(new BlackListSetConf());
}
//初始化配置文件结束
hashtable.put("set", base64Encoder.encode(PublicDataConf.centerSetConf.toJson().getBytes()));
ProFileTools.write(hashtable, "DanmujiProfile");
profileMap.put("set", base64Encoder.encode(PublicDataConf.centerSetConf.toJson().getBytes()));
ProFileTools.write(profileMap, "DanmujiProfile");
try {
PublicDataConf.centerSetConf = JSONObject
.parseObject(new String(base64Encoder.decode(hashtable.get("set"))), CenterSetConf.class);
.parseObject(new String(base64Encoder.decode(profileMap.get("set"))), CenterSetConf.class);
LOGGER.info("读取配置文件成功");
} catch (Exception e) {
// TODO: handle exception
Expand Down Expand Up @@ -163,7 +164,7 @@ public void init(){
checkService.holdSet(PublicDataConf.centerSetConf);
}
base64Encoder = null;
hashtable.clear();
profileMap.clear();
}

@Autowired
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/xyz/acproject/danmuji/config/WebMvcConfig.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package xyz.acproject.danmuji.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.resource.ContentVersionStrategy;
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
import org.springframework.web.servlet.resource.VersionResourceResolver;
import xyz.acproject.danmuji.conf.PublicDataConf;
import xyz.acproject.danmuji.interceptors.LoginInterceptor;

/**
* @author Jane
* @ClassName WebMvcConfigurer
Expand Down Expand Up @@ -38,10 +39,23 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
VersionResourceResolver versionResourceResolver = new VersionResourceResolver()
.addVersionStrategy(new ContentVersionStrategy(), "/**");
registry.addResourceHandler("/**").addResourceLocations("classpath:/static/").setCachePeriod(2592000)
.resourceChain(true).addResolver(versionResourceResolver);
.resourceChain(true).addResolver(versionResourceResolver)
;
// WebMvcConfigurer.super.addResourceHandlers(registry);
}


/**
* 资源url编码过滤器
*
* @return {@link ResourceUrlEncodingFilter}
*/
@Bean
public ResourceUrlEncodingFilter resourceUrlEncodingFilter() {
return new ResourceUrlEncodingFilter();
}


@Autowired
public void setDanmujiConfig(DanmujiInitConfig danmujiInitConfig) {
this.danmujiInitConfig = danmujiInitConfig;
Expand Down
Loading

0 comments on commit 715e07d

Please sign in to comment.