Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加魔女抽奖cd功能,防止刷屏 #1

Open
wants to merge 66 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
1a1831c
add monv cd
yoyodi May 6, 2022
f41b182
restore configuration files
yoyodi May 6, 2022
4f48128
恢复抽卡
yoyodi May 6, 2022
8e7870a
修复时间同步问题
yoyodi May 25, 2022
9d7f8e3
增加魔女统计功能
yoyodi Jun 6, 2022
2dbf04a
修复描述问题
yoyodi Jun 6, 2022
064defc
抽奖结果按日统计
yoyodi Jun 7, 2022
787e295
增加抽奖日报
yoyodi Jun 7, 2022
34c8e1f
修复bug
yoyodi Jun 7, 2022
40892ac
修复bug
yoyodi Jun 7, 2022
fb5b5cf
增加抽奖时间限制
yoyodi Jun 8, 2022
2fba8a4
修复bug
yoyodi Jun 8, 2022
f4a8797
修复bug
yoyodi Jun 8, 2022
9261dbd
完善统计功能
yoyodi Jun 14, 2022
bf632ac
修复bug
yoyodi Jun 14, 2022
ccc9b62
同步v1.1更新内容
yoyodi Jun 24, 2022
294b531
占仆适配CMS希拉区频道数
yoyodi Jun 24, 2022
85c8b90
同步v1.2更新内容
yoyodi Jul 7, 2022
7064ea2
修复bug
yoyodi Jul 8, 2022
efc9f64
增加禁言功能
yoyodi Jul 22, 2022
13553a7
增加解除禁言功能
yoyodi Jul 29, 2022
6068fa2
修复禁言bug
yoyodi Aug 2, 2022
e03b306
优化禁言策略
yoyodi Aug 11, 2022
8f15850
增加roll点功能
yoyodi Oct 14, 2022
d38bfa1
恢复抽卡功能
yoyodi Jan 5, 2023
22549f6
增加定时任务:跑旗提醒
yoyodi Jan 16, 2023
835c448
增加上色和画头像功能
yoyodi Mar 6, 2023
112b80c
增加说话功能
yoyodi Mar 7, 2023
19f1a04
修复bug
yoyodi Mar 7, 2023
d40c5e9
修复bug
yoyodi Mar 7, 2023
716f2f8
更新配置文件
yoyodi Mar 7, 2023
f48b2b9
更新禁言规则
yoyodi Mar 7, 2023
c6ef6b4
更新禁言规则
yoyodi Mar 8, 2023
54547b8
优化禁言提交策略
yoyodi Mar 9, 2023
ffe7ed3
优化禁言策略
yoyodi Mar 10, 2023
c0fe36b
优化禁言功能
yoyodi Mar 10, 2023
2b9d0b8
增加禁言周报功能
yoyodi Mar 14, 2023
c71c29e
增加图片检查功能
yoyodi Mar 17, 2023
124e2a5
修复描述问题
yoyodi Mar 17, 2023
8b1ecbf
修复bug
yoyodi Mar 19, 2023
494192a
修复bug
yoyodi Mar 27, 2023
a99ebf9
修复bug
yoyodi Apr 3, 2023
9f804de
调整禁言策略
yoyodi Apr 10, 2023
c1a654d
调整禁言策略
yoyodi Apr 12, 2023
a336094
调整禁言策略
yoyodi Apr 12, 2023
f9106c9
调整禁言策略
yoyodi Apr 12, 2023
aacc58c
调整禁言策略
yoyodi Apr 12, 2023
4b4b38e
调整禁言策略
yoyodi Apr 14, 2023
ed5c1bc
调整禁言策略
yoyodi Apr 19, 2023
6e7f748
调整禁言策略
yoyodi Apr 19, 2023
43484fa
调整禁言策略
yoyodi Apr 19, 2023
9e79073
调整禁言策略
yoyodi Apr 19, 2023
a8e5f90
增加查成分功能
yoyodi May 6, 2023
0de0792
增加查成分功能
yoyodi May 6, 2023
692fc33
抽卡功能更新
yoyodi Jun 17, 2023
355d145
抽卡功能更新
yoyodi Jun 17, 2023
d6429b6
调整缩放比例
yoyodi Jun 17, 2023
c7b3a5d
调整缩放比例
yoyodi Jun 20, 2023
d51341b
调整图片合成质量
yoyodi Jun 20, 2023
f8c73eb
调整缩放比例
yoyodi Jun 20, 2023
7ec35dd
调整入群欢迎
yoyodi Jul 3, 2023
75d938d
同步v2.0修改
yoyodi Jul 7, 2023
a877fa2
同步v2.1无视计算部分修改
yoyodi Aug 10, 2023
69f836b
add Erniebot
yoyodi Mar 1, 2024
14af33e
fix ErnieBotMsg
yoyodi Apr 11, 2024
a24f747
fix sendErnieBotMsg
yoyodi Apr 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

前台监听地址 host: 127.0.0.1 port: 5700

视频搭建流程 https://www.bilibili.com/video/BV14R4y1G7sM
# 视频搭建流程:

Linux服务器搭建:https://www.bilibili.com/video/BV14R4y1G7sM

windows服务器搭建:https://www.bilibili.com/video/BV1pW4y1r7JS

## 静态资源

Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation('org.springframework.boot:spring-boot-starter-thymeleaf')
implementation('com.squareup.okhttp3:okhttp:5.0.0-alpha.2')
runtimeOnly('com.h2database:h2')
runtimeOnly 'mysql:mysql-connector-java'
testImplementation('org.springframework.boot:spring-boot-starter-test')
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
</parent>
<groupId>com.badeling</groupId>
<artifactId>msbot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<inceptionYear>2014</inceptionYear>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/badeling/msbot/MsbotApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

import com.badeling.msbot.domain.ReRead;

import java.util.TimeZone;

@SpringBootApplication
@EnableConfigurationProperties({ReRead.class})
public class MsbotApplication {

public static void main(String[] args) {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
SpringApplication.run(MsbotApplication.class, args);
}

Expand Down
25 changes: 15 additions & 10 deletions src/main/java/com/badeling/msbot/config/MsbotConst.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.badeling.msbot.config;

public class MsbotConst {

//go cqhttp本体
public static final String miraiUrl = "D:/go-cqhttp";
//go-cqhttp图片目录
public static final String imageUrl = miraiUrl + "/data/images/";
//go-cqhttp音频目录
public static final String voiceUrl = miraiUrl + "/data/voices/";
//机器人昵称
public static final String botName = "蠢猫";
//自己的昵称
//自己的昵称
public static final String masterName = "BadeLing";
//机器人qq号
public static final String botId = "123456";
Expand All @@ -18,21 +20,24 @@ public class MsbotConst {
public static final String[] managerId = {"123","223"};
//拉黑的qq号
public static final String[] blackList = {"323","423"};


//魔女cd 单位秒
public static final int monv_cd = 120;

//第三方机器人 也就是上面登录的账号 允许发言的频道 QQ频道发一句话 然后后台查看频道id
//"channel_id":"1609899"
public static final String[] botChannel = {"1609899"};

//茉莉机器人key
public static final String moliKey = "";
//茉莉机器人Secret
public static final String moliSecret = "";

//茉莉机器人key 可以和上面填一样 一个是官方频道机器人用的 一个是上面登录的第三方机器人用的
public static final String moliKey2 = "";
//茉莉机器人Secret
public static final String moliSecret2 = "";

//百度云识图Key 可不填 只影响 识图和起源39自动识别功能 原本的气象功能已废弃
//百度云识图 普通模式每天免费5w次 高精度模式每天免费500次
public static final String baiduKey = "";
Expand All @@ -43,7 +48,7 @@ public class MsbotConst {
//百度翻译key
public static final String securityKey="";


//腾讯云key 这个可以不填 是为官方机器人用的 这个以后有条件再教
public static final String tencentSecretId = "";
//腾讯云Secret
Expand All @@ -52,10 +57,10 @@ public class MsbotConst {
public static final String bucketName = "image";
//存储桶地址
public static final String bucketRegion = "ap-chengdu";

//QQ频道官方机器人
public static final String channelBotId = "123456";
//QQ频道官方机器人 昵称
public static final String channelBotName = "拉拉";
}

}
152 changes: 150 additions & 2 deletions src/main/java/com/badeling/msbot/controller/ApplicationRunnerImpl.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,170 @@
package com.badeling.msbot.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import com.badeling.msbot.domain.GlobalVariable;
import com.badeling.msbot.domain.GroupMsg;
import com.badeling.msbot.domain.Result;
import com.badeling.msbot.entity.GroupInfo;
import com.badeling.msbot.entity.GroupMember;
import com.badeling.msbot.repository.GroupInfoRepository;
import com.badeling.msbot.repository.GroupMemberRepository;
import com.badeling.msbot.service.GroupMsgService;

@Component
public class ApplicationRunnerImpl implements ApplicationRunner{
//public class ApplicationRunnerImpl{


@Autowired
GroupMsgService groupMsgService;

@Autowired
GroupInfoRepository groupInfoRepository;

@Autowired
GroupMemberRepository groupMemberRepository;

@Override
public void run(ApplicationArguments args) throws Exception {
TreeSet<String> msgList = new TreeSet<>();
GlobalVariable.setMsgList(msgList);
Map<String,Long> newFriendsList = new HashMap<>();
GlobalVariable.setNewFriendsMap(newFriendsList);
Map<String,Long> witchForestMap = new HashMap<>();
GlobalVariable.setWitchForestMap(witchForestMap);


System.out.println("初始程序执行完毕");

List<String> list = new ArrayList<String>();
//获取群列表
try {
Result<?> groupList = groupMsgService.getGroupList();

if(groupList.getStatus().equals("ok")) {
@SuppressWarnings("unchecked")
List<Map<String,Object>> data = (List<Map<String, Object>>) groupList.getData();
int countGroup = 0;
int addGroup = 0;
for(Map<String,Object> mapElement : data) {
GroupInfo groupInfo = new GroupInfo();
list.add(""+mapElement.get("group_id"));
String group_id = ""+mapElement.get("group_id");
String group_name = ""+mapElement.get("group_name");
String group_memo = ""+mapElement.get("group_memo");
GroupInfo findByGroupId = groupInfoRepository.findByGroupId(group_id);
if(findByGroupId==null) {
groupInfo.setGroup_id(group_id);
groupInfo.setGroup_name(group_name);
groupInfo.setGroup_memo(group_memo);
groupInfoRepository.save(groupInfo);
addGroup++;
}
countGroup++;
}
System.out.println("共获取"+countGroup+"个群,新增群聊"+addGroup+"个");
}
} catch (Exception e) {
// 获取群列表失败
e.printStackTrace();
System.out.println("获取群列表失败");
}


try {
//更新群成员信息
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
int countAdd = 0;
int countModify = 0;
int countLeave = 0;
int countSame = 0;
Long startTime = System.currentTimeMillis();
List<GroupMember> addList = new ArrayList<GroupMember>();
for(String group_id : list) {
GroupMsg groupMsg = new GroupMsg();
groupMsg.setGroup_id(Long.parseLong(group_id));
Result<?> groupMemberList = groupMsgService.getGroupMember(groupMsg);
List<GroupMember> findGroupMemberList = groupMemberRepository.findGroupMemberByGroup(group_id);
Map<String,GroupMember> groupMemberMap = new HashMap<String, GroupMember>();
for(GroupMember groupMember : findGroupMemberList) {
groupMemberMap.put(groupMember.getUser_id(), groupMember);
}

@SuppressWarnings("unchecked")
List<Map<String,Object>> data = (List<Map<String, Object>>) groupMemberList.getData();
for(Map<String,Object> map : data) {
String user_id = String.valueOf(map.get("user_id"));
if(groupMemberMap.containsKey(user_id)) {
GroupMember groupMember = groupMemberMap.get(user_id);
groupMemberMap.remove(user_id);
String leave_time = groupMember.getLeave_time();
if(leave_time!=null&&!leave_time.isEmpty()) {
groupMemberRepository.modifyMemberLeaveTime(groupMember.getId(),"");
}
if(groupMember.getCard().equals(String.valueOf(map.get("card")))&&groupMember.getNickname().equals(String.valueOf(map.get("nickname")))) {
countSame++;
continue;
}else {
countModify++;
groupMemberRepository.modifyMemberInfo(groupMember.getId(), String.valueOf(map.get("nickname")), String.valueOf(map.get("card")), sdf.format(Long.parseLong(map.get("join_time")+"000")));
}
}else {
String time = sdf.format(Long.parseLong(map.get("join_time")+"000"));
GroupMember groupMember = new GroupMember();
groupMember.setCard(String.valueOf(map.get("card")));
groupMember.setGroup_id(group_id);
groupMember.setJoin_time(time);
groupMember.setLeave_time(null);
groupMember.setNickname(String.valueOf(map.get("nickname")));
groupMember.setUser_id(user_id);
addList.add(groupMember);
countAdd++;
}
}

if(!groupMemberMap.isEmpty()) {
String time = sdf.format(System.currentTimeMillis());
for(String temp : groupMemberMap.keySet()) {
GroupMember groupMember = groupMemberMap.get(temp);
if(groupMember.getLeave_time()==null||groupMember.getLeave_time().isEmpty()) {
groupMemberRepository.modifyMemberLeaveTime(groupMember.getId(), time);
countLeave++;
continue;
}
try {
if(Integer.parseInt(groupMember.getJoin_time())>Integer.parseInt(groupMember.getLeave_time())) {
groupMemberRepository.modifyMemberLeaveTime(groupMember.getId(), time);
countLeave++;
continue;
}
} catch (Exception e) {
System.out.println("统计减少人数时出错:"+groupMember.toString());
}
}
}

if(addList.size()>0) {
groupMemberRepository.saveAll(addList);
}
}
System.out.println("更新群成员信息成功:新增"+countAdd+"人,更新"+countModify+"人,离开"+countLeave+"人,保持"+countSame+"人,耗时"+((startTime-System.currentTimeMillis())/1000)+"ms");
} catch (Exception e) {
e.printStackTrace();
System.out.println("更新群成员信息失败");
}



}

}
}
Loading