├── README.md ├── Robot-web ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── hyq │ │ │ └── robot │ │ │ ├── controller │ │ │ └── TestController.java │ │ │ └── MiraiRobotStar.java │ │ └── resources │ │ ├── application.properties │ │ └── logback-spring.xml └── pom.xml ├── Robot-dao ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── hyq │ │ │ └── robot │ │ │ ├── config │ │ │ ├── FilePathConstant.java │ │ │ ├── DataSourceProperty.java │ │ │ └── DataSourceConfig.java │ │ │ ├── query │ │ │ ├── BarPostQuery.java │ │ │ ├── TeamQuery.java │ │ │ ├── InformRelationQuery.java │ │ │ ├── OpenServiceSubscribeQuery.java │ │ │ ├── ServiceStatusRecordQuery.java │ │ │ ├── TeamMemberQuery.java │ │ │ ├── MainServiceQuery.java │ │ │ ├── SubServiceQuery.java │ │ │ ├── PostLinkQuery.java │ │ │ └── BaseQuery.java │ │ │ ├── dao │ │ │ ├── BarPostDAO.java │ │ │ ├── PostLinkDAO.java │ │ │ ├── InformRelationDAO.java │ │ │ ├── TeamDAO.java │ │ │ ├── SubServiceDAO.java │ │ │ ├── MainServiceDAO.java │ │ │ ├── TeamMemberDAO.java │ │ │ ├── ServiceStatusRecordDAO.java │ │ │ └── OpenServiceSubscribeDAO.java │ │ │ └── DO │ │ │ ├── TeamDO.java │ │ │ ├── InformRelationDO.java │ │ │ ├── BarPostDO.java │ │ │ ├── PostLinkDO.java │ │ │ ├── SubServiceDO.java │ │ │ ├── OpenServiceSubscribeDO.java │ │ │ ├── TeamMemberDO.java │ │ │ ├── ServiceStatusRecordDO.java │ │ │ └── MainServiceDO.java │ │ └── resources │ │ └── mapper │ │ ├── SubServiceDAO.xml │ │ ├── BarPostDAO.xml │ │ ├── TeamDAO.xml │ │ ├── MainServiceDAO.xml │ │ ├── InformRelationDAO.xml │ │ ├── OpenServiceSubscribeDAO.xml │ │ ├── ServiceStatusRecordDAO.xml │ │ ├── PostLinkDAO.xml │ │ └── TeamMemberDAO.xml └── pom.xml ├── Robot-core ├── src │ └── main │ │ └── java │ │ └── com │ │ └── hyq │ │ └── robot │ │ ├── constants │ │ ├── ApiURLConstant.java │ │ └── CommonConstant.java │ │ ├── facade │ │ ├── message │ │ │ ├── MessageFacade.java │ │ │ ├── team │ │ │ │ ├── CancelKaiTuanFacade.java │ │ │ │ ├── KaiTuanFacade.java │ │ │ │ ├── TeamFacade.java │ │ │ │ ├── ChaKanTuanDuiFacade.java │ │ │ │ ├── CancelBaoMingFacade.java │ │ │ │ ├── JiaoHuanFacade.java │ │ │ │ └── BaoMingFacade.java │ │ │ ├── kaifujiankong │ │ │ │ ├── KaiFuJianKongFacade.java │ │ │ │ ├── QuXiaoJianKongFacade.java │ │ │ │ └── KaiFuChaXunFacade.java │ │ │ └── waiguan │ │ │ │ └── SelectFacade.java │ │ ├── MessageFactory.java │ │ └── trans │ │ │ └── OpenServiceTrans.java │ │ ├── enums │ │ ├── EnumOpenStatus.java │ │ ├── EnumKeyWord.java │ │ └── EnumPosition.java │ │ ├── utils │ │ ├── DateUtil.java │ │ ├── NetworkUtil.java │ │ ├── MessageUtil.java │ │ ├── TieBaUtil.java │ │ └── GroupMemberUtil.java │ │ ├── helper │ │ ├── ApplicationContextHelper.java │ │ └── SendHelper.java │ │ ├── repository │ │ ├── AiChatRepository.java │ │ └── OneEnglishRepository.java │ │ ├── config │ │ └── InitBeanConfig.java │ │ ├── autojob │ │ ├── GoodMorningTask.java │ │ ├── OpenServiceTask.java │ │ └── CreeperTask.java │ │ └── listener │ │ ├── GroupListener.java │ │ └── OpenListener.java └── pom.xml ├── .gitignore ├── Robot-client ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── hyq │ └── robot │ └── client │ ├── CreeperClient.java │ └── HttpClient.java ├── sql-file ├── team.sql ├── inform_relation.sql ├── post_link.sql ├── bar_post.sql └── team_member.sql └── pom.xml /README.md: -------------------------------------------------------------------------------- 1 | 摩西摩西,对应MySQL建表语句相见sql-file文件按需创建 2 | 3 |

1、贴吧相关

4 | bar_post.sql、inform_relation.sql、post_link.sql 5 | --- 6 |

2、开团助手

7 | team.sql、team_member.sql 8 | --- 9 |

3、开服监控

10 | 不维护了,表已被删,如需要请对应mapper.xml见文件自己还原 11 | --- 12 | -------------------------------------------------------------------------------- /Robot-web/src/main/java/com/hyq/robot/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.controller; 2 | 3 | import org.springframework.web.bind.annotation.RestController; 4 | 5 | /** 6 | * @author nanke 7 | * @date 2020/7/14 下午4:54 8 | */ 9 | @RestController 10 | public class TestController { 11 | 12 | 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Robot-web/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | server.port=8080 3 | 4 | spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=true 5 | 6 | #数据库 7 | mysql.url=jdbc:mysql://rm-bp1b934u5x6g031597o.mysql.rds.aliyuncs.com/robot?useUnicode=true;characterEncoding=UTF-8;&serverTimezone=GMT%2B8 8 | mysql.name= 9 | mysql.passWord= 10 | mysql.driverClass=com.mysql.cj.jdbc.Driver -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/config/FilePathConstant.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.config; 2 | 3 | /** 4 | * @author nanke 5 | * @date 2020/4/4 下午2:26 6 | */ 7 | public interface FilePathConstant { 8 | 9 | /** 10 | * Dao包路径 11 | */ 12 | String DAO_PACKAGE = "com.hyq.robot.dao"; 13 | /** 14 | * Dao配置包路径 15 | */ 16 | String MAPPER_PACKAGE = "classpath*:mapper/*.xml"; 17 | } 18 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/constants/ApiURLConstant.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.constants; 2 | 3 | /** 4 | * @author nanke 5 | * @date 2020/7/22 下午12:25 6 | */ 7 | public interface ApiURLConstant { 8 | 9 | String loveURL = "https://s.nmsl8.club/loveword?type=1"; 10 | 11 | String fuckURL = "https://s.nmsl8.club/loveword?type=2"; 12 | 13 | String chickenSoupURL = "https://s.nmsl8.club/loveword?type=4"; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Robot-web/src/main/java/com/hyq/robot/MiraiRobotStar.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * @author nanke 8 | * @date 2020/7/14 上午11:49 9 | */ 10 | @SpringBootApplication 11 | public class MiraiRobotStar { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(MiraiRobotStar.class,args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | out/ 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/query/BarPostQuery.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.query; 2 | 3 | import lombok.*; 4 | 5 | /** 6 | * @author nanke 7 | * @date 2020/4/4 下午9:04 8 | */ 9 | @Data 10 | @Builder 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | @EqualsAndHashCode(callSuper = false) 14 | public class BarPostQuery extends BaseQuery{ 15 | 16 | /** 17 | * 帖子链接 18 | */ 19 | private String postUrl; 20 | /** 21 | * 0:否 1:删除 22 | */ 23 | private Integer delete; 24 | } 25 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/dao/BarPostDAO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.dao; 2 | 3 | import com.hyq.robot.DO.BarPostDO; 4 | import com.hyq.robot.query.BarPostQuery; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author nanke 10 | * @date 2020/4/4 11 | */ 12 | public interface BarPostDAO { 13 | 14 | /** 15 | * 批量插入 16 | * @param dos 17 | */ 18 | void insertBatch(List dos); 19 | /** 20 | * 条件查询,默认分页 21 | * @param query 22 | * @return 23 | */ 24 | List queryByCondition(BarPostQuery query); 25 | } 26 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/dao/PostLinkDAO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.dao; 2 | 3 | import com.hyq.robot.DO.PostLinkDO; 4 | import com.hyq.robot.query.PostLinkQuery; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author nanke 10 | * @date 2020/4/12 11 | */ 12 | public interface PostLinkDAO { 13 | 14 | /** 15 | * 选择性插入 16 | * @param insertDO 17 | */ 18 | void insertSelective(PostLinkDO insertDO); 19 | 20 | /** 21 | * 条件查询 22 | * @param query 23 | * @return 24 | */ 25 | List queryByCondition(PostLinkQuery query); 26 | } 27 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/query/TeamQuery.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.query; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | /** 7 | * @author nanke 8 | * @date 2020/7/22 9 | */ 10 | @Data 11 | @EqualsAndHashCode(callSuper = false) 12 | public class TeamQuery extends BaseQuery { 13 | 14 | /** 15 | * 主键 16 | */ 17 | private Long id; 18 | /** 19 | * 团标题 20 | */ 21 | private String teamName; 22 | /** 23 | * QQ群ID 24 | */ 25 | private Long groupId; 26 | /** 27 | * 0:否 1:删除 28 | */ 29 | private Integer delete; 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/dao/InformRelationDAO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.dao; 2 | import com.hyq.robot.DO.InformRelationDO; 3 | import com.hyq.robot.query.InformRelationQuery; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author nanke 9 | * @date 2020/4/12 10 | */ 11 | public interface InformRelationDAO { 12 | 13 | /** 14 | * 选择性插入 15 | * @param insertDO 16 | */ 17 | void insertSelective(InformRelationDO insertDO); 18 | 19 | /** 20 | * 条件查询 21 | * @param query 22 | * @return 23 | */ 24 | List queryByCondition(InformRelationQuery query); 25 | } 26 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/query/InformRelationQuery.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.query; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | /** 7 | * @author nanke 8 | * @date 2020/4/12 9 | */ 10 | @Data 11 | @EqualsAndHashCode(callSuper = false) 12 | public class InformRelationQuery extends BaseQuery { 13 | 14 | /** 15 | * 主键 16 | */ 17 | private Long id; 18 | /** 19 | * 帖子链接ID 20 | */ 21 | private Long postLinkId; 22 | /** 23 | * QQ群号 24 | */ 25 | private Long groupId; 26 | /** 27 | * 0:否 1:删除 28 | */ 29 | private Integer delete; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/query/OpenServiceSubscribeQuery.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.query; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | /** 7 | * @author nanke 8 | * @date 2021-1-6 9 | * 致终于来到这里的勇敢的人: 10 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 11 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 12 | */ 13 | @Data 14 | @EqualsAndHashCode(callSuper = false) 15 | public class OpenServiceSubscribeQuery extends BaseQuery { 16 | 17 | /** 18 | * 主服务ID 19 | */ 20 | private Long mainId; 21 | /** 22 | * QQ群ID 23 | */ 24 | private Long groupId; 25 | /** 26 | * 0:否 1:删除 27 | */ 28 | private Integer delete; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/query/ServiceStatusRecordQuery.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.query; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | /** 7 | * @author nanke 8 | * @date 2021-1-4 9 | * 致终于来到这里的勇敢的人: 10 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 11 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 12 | */ 13 | @Data 14 | @EqualsAndHashCode(callSuper = false) 15 | public class ServiceStatusRecordQuery extends BaseQuery { 16 | 17 | /** 18 | * 主服务ID 19 | */ 20 | private Long mainId; 21 | /** 22 | * 0:维护 1:开服 23 | */ 24 | private Integer openStatus; 25 | /** 26 | * 0:否 1:删除 27 | */ 28 | private Integer delete; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/dao/TeamDAO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.dao; 2 | 3 | import com.hyq.robot.DO.TeamDO; 4 | import com.hyq.robot.query.TeamQuery; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author nanke 10 | * @date 2020/7/22 11 | */ 12 | public interface TeamDAO { 13 | 14 | /** 15 | * 选择性插入 16 | * @param insertDO 17 | */ 18 | void insertSelective(TeamDO insertDO); 19 | 20 | /** 21 | * 根据群删除团 22 | * @param updateDO 23 | */ 24 | void updateById(TeamDO updateDO); 25 | 26 | /** 27 | * 条件查询 28 | * @param query 29 | * @return 30 | */ 31 | List queryByCondition(TeamQuery query); 32 | } 33 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/DO/TeamDO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.DO; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author nanke 9 | * @date 2020/7/22 10 | */ 11 | @Data 12 | public class TeamDO { 13 | 14 | /** 15 | * 主键 16 | */ 17 | private Long id; 18 | /** 19 | * 团标题 20 | */ 21 | private String teamName; 22 | /** 23 | * QQ群ID 24 | */ 25 | private Long groupId; 26 | /** 27 | * 修改时间 28 | */ 29 | private Date gmtModify; 30 | /** 31 | * 创建时间 32 | */ 33 | private Date gmtCreate; 34 | /** 35 | * 0:否 1:删除 36 | */ 37 | private Integer delete; 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/dao/SubServiceDAO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.dao; 2 | 3 | import com.hyq.robot.DO.SubServiceDO; 4 | import com.hyq.robot.query.SubServiceQuery; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author nanke 10 | * @date 2021-1-4 11 | * 致终于来到这里的勇敢的人: 12 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 13 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 14 | */ 15 | public interface SubServiceDAO { 16 | 17 | /** 18 | * 条件查询 19 | * @param query 20 | * @return 21 | */ 22 | List queryByCondition(SubServiceQuery query); 23 | 24 | /** 25 | * 条件查询总数 26 | * @return 27 | */ 28 | Long countByCondition(SubServiceQuery query); 29 | 30 | } -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/query/TeamMemberQuery.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.query; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | /** 7 | * @author nanke 8 | * @date 2020/7/22 9 | */ 10 | @Data 11 | @EqualsAndHashCode(callSuper = false) 12 | public class TeamMemberQuery extends BaseQuery { 13 | 14 | /** 15 | * 主键 16 | */ 17 | private Long id; 18 | /** 19 | * 团ID 20 | */ 21 | private Long teamId; 22 | /** 23 | * 队伍位置 24 | */ 25 | private Long location; 26 | /** 27 | * QQ 28 | */ 29 | private Long qq; 30 | /** 31 | * 0:否 1:删除 32 | */ 33 | private Integer delete; 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/query/MainServiceQuery.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.query; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @author nanke 10 | * @date 2021-1-4 11 | * 致终于来到这里的勇敢的人: 12 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 13 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 14 | */ 15 | @Data 16 | @EqualsAndHashCode(callSuper = false) 17 | public class MainServiceQuery extends BaseQuery { 18 | 19 | /** 20 | * 主服务ID 21 | */ 22 | private Long mainId; 23 | /** 24 | * 0:维护 1:开服 25 | */ 26 | private Integer openStatus; 27 | /** 28 | * 0:否 1:删除 29 | */ 30 | private Integer delete; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/DO/InformRelationDO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.DO; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author nanke 9 | * @date 2020/4/12 10 | */ 11 | @Data 12 | public class InformRelationDO { 13 | 14 | /** 15 | * 主键 16 | */ 17 | private Long id; 18 | /** 19 | * 帖子链接ID 20 | */ 21 | private Long postLinkId; 22 | /** 23 | * QQ群号 24 | */ 25 | private Long groupId; 26 | /** 27 | * 修改时间 28 | */ 29 | private Date gmtModify; 30 | /** 31 | * 创建时间 32 | */ 33 | private Date gmtCreate; 34 | /** 35 | * 0:否 1:删除 36 | */ 37 | private Integer delete; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/message/MessageFacade.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.message; 2 | 3 | import com.hyq.robot.enums.EnumKeyWord; 4 | import net.mamoe.mirai.contact.Contact; 5 | import net.mamoe.mirai.message.data.Message; 6 | 7 | import java.io.IOException; 8 | 9 | /** 10 | * @author nanke 11 | * @date 2020/7/22 下午1:06 12 | */ 13 | public interface MessageFacade { 14 | 15 | /** 16 | * 关键字诶类型 17 | * @return 18 | */ 19 | public EnumKeyWord get(); 20 | 21 | /** 22 | * 操作 23 | * @param sender 24 | * @param group 25 | * @param message 26 | */ 27 | public void execute(Contact sender, Contact group, Message message) throws IOException; 28 | } 29 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/config/DataSourceProperty.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * @author nanke 9 | * @date 2020/4/4 下午2:31 10 | */ 11 | @Data 12 | @Component 13 | @ConfigurationProperties(prefix = "mysql") 14 | public class DataSourceProperty { 15 | 16 | /** 17 | * 连接 18 | */ 19 | private String url; 20 | /** 21 | * 账号 22 | */ 23 | private String name; 24 | /** 25 | * 密码 26 | */ 27 | private String passWord; 28 | /** 29 | * 驱动类 30 | */ 31 | private String driverClass; 32 | } 33 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/query/SubServiceQuery.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.query; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @author nanke 10 | * @date 2021-1-4 11 | * 致终于来到这里的勇敢的人: 12 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 13 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 14 | */ 15 | @Data 16 | @EqualsAndHashCode(callSuper = false) 17 | public class SubServiceQuery extends BaseQuery { 18 | 19 | /** 20 | * 子服务ID 21 | */ 22 | private Long subId; 23 | /** 24 | * 主服务ID 25 | */ 26 | private Long mainId; 27 | /** 28 | * 服务器名称 29 | */ 30 | private String subServiceName; 31 | /** 32 | * 0:否 1:删除 33 | */ 34 | private Integer delete; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/dao/MainServiceDAO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.dao; 2 | 3 | import com.hyq.robot.DO.MainServiceDO; 4 | import com.hyq.robot.query.MainServiceQuery; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author nanke 10 | * @date 2021-1-4 11 | * 致终于来到这里的勇敢的人: 12 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 13 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 14 | */ 15 | public interface MainServiceDAO { 16 | 17 | /** 18 | * 条件查询 19 | * @param query 20 | * @return 21 | */ 22 | List queryByCondition(MainServiceQuery query); 23 | 24 | /** 25 | * 主键更新 26 | * @param updateDO 27 | */ 28 | void updateById(MainServiceDO updateDO); 29 | 30 | /** 31 | * 条件查询总数 32 | * @return 33 | */ 34 | Long countByCondition(MainServiceQuery query); 35 | 36 | } -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/DO/BarPostDO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.DO; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author nanke 9 | * @date 2020/4/4 10 | */ 11 | @Data 12 | public class BarPostDO { 13 | 14 | /** 15 | * 主键 16 | */ 17 | private Long id; 18 | /** 19 | * 楼层 20 | */ 21 | private Long floorId; 22 | /** 23 | * 楼层内容 24 | */ 25 | private String content; 26 | /** 27 | * 帖子链接 28 | */ 29 | private String postUrl; 30 | /** 31 | * 当前页数 32 | */ 33 | private Integer pageNo; 34 | /** 35 | * 修改时间 36 | */ 37 | private Date gmtModify; 38 | /** 39 | * 创建时间 40 | */ 41 | private Date gmtCreate; 42 | /** 43 | * 0:否 1:删除 44 | */ 45 | private Integer delete; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/DO/PostLinkDO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.DO; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author nanke 9 | * @date 2020/4/12 10 | */ 11 | @Data 12 | public class PostLinkDO { 13 | 14 | /** 15 | * 主键 16 | */ 17 | private Long id; 18 | /** 19 | * 区服ID 20 | */ 21 | private Long area; 22 | /** 23 | * 区服务名 24 | */ 25 | private String areaName; 26 | /** 27 | * 帖子链接类型 28 | */ 29 | private Long linkType; 30 | /** 31 | * 帖子链接地址 32 | */ 33 | private String linkUrl; 34 | /** 35 | * 修改时间 36 | */ 37 | private Date gmtModify; 38 | /** 39 | * 创建时间 40 | */ 41 | private Date gmtCreate; 42 | /** 43 | * 0:否 1:删除 44 | */ 45 | private Integer delete; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/DO/SubServiceDO.java: -------------------------------------------------------------------------------- 1 | 2 | package com.hyq.robot.DO; 3 | 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * @author nanke 11 | * @date 2021-1-4 12 | * 致终于来到这里的勇敢的人: 13 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 14 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 15 | */ 16 | @Data 17 | public class SubServiceDO implements Serializable { 18 | 19 | /** 20 | * 子服务ID 21 | */ 22 | private Long subId; 23 | /** 24 | * 主服务ID 25 | */ 26 | private Long mainId; 27 | /** 28 | * 服务器名称 29 | */ 30 | private String subServiceName; 31 | /** 32 | * 修改时间 33 | */ 34 | private Date gmtModify; 35 | /** 36 | * 创建时间 37 | */ 38 | private Date gmtCreate; 39 | /** 40 | * 0:否 1:删除 41 | */ 42 | private Integer delete; 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/dao/TeamMemberDAO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.dao; 2 | 3 | import com.hyq.robot.DO.TeamMemberDO; 4 | import com.hyq.robot.query.TeamMemberQuery; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author nanke 10 | * @date 2020/7/22 11 | */ 12 | public interface TeamMemberDAO { 13 | 14 | /** 15 | * 选择性插入 16 | * @param insertDO 17 | */ 18 | void insertSelective(TeamMemberDO insertDO); 19 | 20 | /** 21 | * 根据ID取消报名 22 | * @param updateDO 23 | */ 24 | void updateById(TeamMemberDO updateDO); 25 | 26 | /** 27 | * 根据ID调整位置 28 | * @param updateDO 29 | */ 30 | void updateLocationById(TeamMemberDO updateDO); 31 | 32 | /** 33 | * 条件查询 34 | * @param query 35 | * @return 36 | */ 37 | List queryByCondition(TeamMemberQuery query); 38 | } 39 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/MessageFactory.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade; 2 | 3 | import com.hyq.robot.enums.EnumKeyWord; 4 | import com.hyq.robot.facade.message.MessageFacade; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author nanke 12 | * @date 2020/7/22 下午1:03 13 | */ 14 | @Component 15 | public class MessageFactory { 16 | 17 | @Autowired 18 | private List messageFacades; 19 | 20 | public MessageFacade get(EnumKeyWord keyWord) { 21 | 22 | for (MessageFacade messageFacade : messageFacades) { 23 | if (messageFacade.get().equals(keyWord)) { 24 | return messageFacade; 25 | } 26 | } 27 | return null; 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/query/PostLinkQuery.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.query; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | /** 7 | * @author nanke 8 | * @date 2020/4/12 9 | */ 10 | @Data 11 | @EqualsAndHashCode(callSuper = false) 12 | public class PostLinkQuery extends BaseQuery { 13 | 14 | public PostLinkQuery() { 15 | } 16 | 17 | public PostLinkQuery(String areaName) { 18 | this.areaName = areaName; 19 | } 20 | 21 | /** 22 | * 主键 23 | */ 24 | private Long id; 25 | /** 26 | * 区服ID 27 | */ 28 | private Long area; 29 | /** 30 | * 区服务名 31 | */ 32 | private String areaName; 33 | /** 34 | * 帖子链接类型 35 | */ 36 | private Long linkType; 37 | /** 38 | * 帖子链接地址 39 | */ 40 | private String linkUrl; 41 | /** 42 | * 0:否 1:删除 43 | */ 44 | private Integer delete; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/DO/OpenServiceSubscribeDO.java: -------------------------------------------------------------------------------- 1 | 2 | package com.hyq.robot.DO; 3 | 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * @author nanke 11 | * @date 2021-1-6 12 | * 致终于来到这里的勇敢的人: 13 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 14 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 15 | */ 16 | @Data 17 | public class OpenServiceSubscribeDO implements Serializable { 18 | 19 | /** 20 | * 记录ID 21 | */ 22 | private Long id; 23 | /** 24 | * 主服务ID 25 | */ 26 | private Long mainId; 27 | /** 28 | * QQ 29 | */ 30 | private Long qq; 31 | /** 32 | * QQ群ID 33 | */ 34 | private Long groupId; 35 | /** 36 | * 修改时间 37 | */ 38 | private Date gmtModify; 39 | /** 40 | * 创建时间 41 | */ 42 | private Date gmtCreate; 43 | /** 44 | * 0:否 1:删除 45 | */ 46 | private Integer delete; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/enums/EnumOpenStatus.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.enums; 2 | 3 | /** 4 | * @author nanke 5 | * @date 2021/1/6 下午3:14 6 | * 致终于来到这里的勇敢的人: 7 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 8 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 9 | */ 10 | public enum EnumOpenStatus { 11 | 12 | OPEN(1,"开服"), 13 | CLOSE(0,"维护"), 14 | ; 15 | 16 | EnumOpenStatus(Integer status, String desc) { 17 | this.status = status; 18 | this.desc = desc; 19 | } 20 | 21 | /** 22 | * 开服状态 23 | */ 24 | public Integer status; 25 | /** 26 | * 描述 27 | */ 28 | public String desc; 29 | 30 | public static EnumOpenStatus get(Integer status) { 31 | for (EnumOpenStatus value : EnumOpenStatus.values()) { 32 | if (value.status.equals(status)) { 33 | return value; 34 | } 35 | } 36 | return EnumOpenStatus.CLOSE; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/DO/TeamMemberDO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.DO; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author nanke 9 | * @date 2020/7/22 10 | */ 11 | @Data 12 | public class TeamMemberDO { 13 | 14 | /** 15 | * 主键 16 | */ 17 | private Long id; 18 | /** 19 | * 团ID 20 | */ 21 | private Long teamId; 22 | /** 23 | * 队伍位置 24 | */ 25 | private Long location; 26 | /** 27 | * 职业 28 | */ 29 | private String position; 30 | /** 31 | * 填充颜色 32 | */ 33 | private String color; 34 | /** 35 | * 角色名 36 | */ 37 | private String memberName; 38 | /** 39 | * QQ 40 | */ 41 | private Long qq; 42 | /** 43 | * 修改时间 44 | */ 45 | private Date gmtModify; 46 | /** 47 | * 创建时间 48 | */ 49 | private Date gmtCreate; 50 | /** 51 | * 0:否 1:删除 52 | */ 53 | private Integer delete; 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/utils/DateUtil.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.utils; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | /** 7 | * @author nanke 8 | * @date 2021/1/6 下午5:17 9 | * 致终于来到这里的勇敢的人: 10 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 11 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 12 | */ 13 | public class DateUtil { 14 | 15 | private static final SimpleDateFormat YMDHMS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 16 | 17 | private static final SimpleDateFormat YMD = new SimpleDateFormat("yyyy-MM-dd"); 18 | 19 | public static String toYMDHMS(Date date) { 20 | try { 21 | return YMDHMS.format(date); 22 | } catch (Exception e) { 23 | return ""; 24 | } 25 | } 26 | 27 | public static String toYMD(Date date) { 28 | try { 29 | return YMD.format(date); 30 | } catch (Exception e) { 31 | return ""; 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Robot-dao/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Mirai-Robot 7 | com.hyq.robot 8 | ${botVersion} 9 | 10 | 11 | 4.0.0 12 | 13 | Robot-dao 14 | 15 | 16 | 17 | 18 | org.springframework.boot 19 | spring-boot-maven-plugin 20 | 21 | exec 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Robot-client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Mirai-Robot 7 | com.hyq.robot 8 | ${botVersion} 9 | 10 | 11 | 4.0.0 12 | 13 | Robot-client 14 | 15 | 16 | 17 | 18 | org.springframework.boot 19 | spring-boot-maven-plugin 20 | 21 | exec 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/dao/ServiceStatusRecordDAO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.dao; 2 | 3 | 4 | import com.hyq.robot.DO.ServiceStatusRecordDO; 5 | import com.hyq.robot.query.ServiceStatusRecordQuery; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author nanke 11 | * @date 2021-1-4 12 | * 致终于来到这里的勇敢的人: 13 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 14 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 15 | */ 16 | public interface ServiceStatusRecordDAO { 17 | 18 | /** 19 | * 条件查询 20 | * @param query 21 | * @return 22 | */ 23 | List queryByCondition(ServiceStatusRecordQuery query); 24 | 25 | /** 26 | * 新增 27 | * @param insertDO 28 | * @return 29 | */ 30 | void insertSelective(ServiceStatusRecordDO insertDO); 31 | 32 | /** 33 | * 主键更新 34 | * @param updateDO 35 | */ 36 | void updateById(ServiceStatusRecordDO updateDO); 37 | 38 | /** 39 | * 条件查询总数 40 | * @return 41 | */ 42 | Long countByCondition(ServiceStatusRecordQuery query); 43 | 44 | } -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/dao/OpenServiceSubscribeDAO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.dao; 2 | 3 | import com.hyq.robot.DO.OpenServiceSubscribeDO; 4 | import com.hyq.robot.query.OpenServiceSubscribeQuery; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author nanke 10 | * @date 2021-1-6 11 | * 致终于来到这里的勇敢的人: 12 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 13 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 14 | */ 15 | public interface OpenServiceSubscribeDAO { 16 | 17 | /** 18 | * 条件查询 19 | * @param query 20 | * @return 21 | */ 22 | List queryByCondition(OpenServiceSubscribeQuery query); 23 | 24 | /** 25 | * 新增 26 | * @param insertDO 27 | * @return 28 | */ 29 | void insertSelective(OpenServiceSubscribeDO insertDO); 30 | 31 | /** 32 | * 主键更新 33 | * @param updateDO 34 | */ 35 | void updateById(OpenServiceSubscribeDO updateDO); 36 | 37 | /** 38 | * 条件查询总数 39 | * @return 40 | */ 41 | Long countByCondition(OpenServiceSubscribeQuery query); 42 | 43 | } -------------------------------------------------------------------------------- /Robot-web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Mirai-Robot 7 | com.hyq.robot 8 | ${botVersion} 9 | 10 | 11 | 4.0.0 12 | 13 | Robot-web 14 | 15 | 16 | 17 | 18 | com.hyq.robot 19 | Robot-core 20 | ${botVersion} 21 | 22 | 23 | com.alibaba 24 | fastjson 25 | 1.2.76 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/query/BaseQuery.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.query; 2 | 3 | /** 4 | * @author nanke 5 | * @date 2019/10/6 000612:20 6 | */ 7 | public class BaseQuery { 8 | 9 | private Integer pageNo = 1; 10 | 11 | private Integer pageSize = 10; 12 | 13 | private Integer offset; 14 | 15 | public Integer getPageNo() { 16 | return pageNo; 17 | } 18 | 19 | public void setPageNo(Integer pageNo) { 20 | this.pageNo = pageNo; 21 | calculateOffset(); 22 | } 23 | 24 | public Integer getPageSize() { 25 | return pageSize; 26 | } 27 | 28 | public void setPageSize(Integer pageSize) { 29 | this.pageSize = pageSize; 30 | calculateOffset(); 31 | } 32 | 33 | public Integer getOffset() { 34 | calculateOffset(); 35 | return offset; 36 | } 37 | 38 | private void calculateOffset() { 39 | if (null == pageNo || null == pageSize) { 40 | return; 41 | } 42 | offset = (pageNo - 1) * pageSize; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/DO/ServiceStatusRecordDO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.DO; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * @author nanke 10 | * @date 2021-1-4 11 | * 致终于来到这里的勇敢的人: 12 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 13 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 14 | */ 15 | @Data 16 | public class ServiceStatusRecordDO implements Serializable { 17 | 18 | /** 19 | * 主服务ID 20 | */ 21 | private Long id; 22 | /** 23 | * 主服务ID 24 | */ 25 | private Long mainId; 26 | /** 27 | * 服务器名称 28 | */ 29 | private String mainServiceName; 30 | /** 31 | * 开服状态 32 | * @see EnumOpenStatus 33 | */ 34 | private Integer openStatus; 35 | /** 36 | * @see EnumOpenStatus 37 | */ 38 | private String openStatusMsg; 39 | /** 40 | * 修改时间 41 | */ 42 | private Date gmtModify; 43 | /** 44 | * 创建时间 45 | */ 46 | private Date gmtCreate; 47 | /** 48 | * 0:否 1:删除 49 | */ 50 | private Integer delete; 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/DO/MainServiceDO.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.DO; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * @author nanke 10 | * @date 2021-1-4 11 | * 致终于来到这里的勇敢的人: 12 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 13 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 14 | */ 15 | @Data 16 | public class MainServiceDO implements Serializable { 17 | 18 | /** 19 | * 主服务ID 20 | */ 21 | private Long mainId; 22 | /** 23 | * ip地址 24 | */ 25 | private String ipAddress; 26 | /** 27 | * 端口地址 28 | */ 29 | private Integer port; 30 | /** 31 | * 大区名称 32 | */ 33 | private String areaName; 34 | /** 35 | * 服务器名称 36 | */ 37 | private String mainServiceName; 38 | /** 39 | * 0:维护 1:开服 40 | */ 41 | private Integer openStatus; 42 | /** 43 | * 修改时间 44 | */ 45 | private Date gmtModify; 46 | /** 47 | * 创建时间 48 | */ 49 | private Date gmtCreate; 50 | /** 51 | * 0:否 1:删除 52 | */ 53 | private Integer delete; 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/utils/NetworkUtil.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.utils; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.commons.io.IOUtils; 5 | 6 | import javax.net.ssl.HttpsURLConnection; 7 | import java.io.ByteArrayInputStream; 8 | import java.io.ByteArrayOutputStream; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import java.net.URL; 12 | 13 | @Slf4j 14 | public class NetworkUtil { 15 | 16 | /** 17 | * 获取URL输入流 18 | * @param URL 19 | * @return 20 | */ 21 | public static InputStream getInputStream(String URL){ 22 | HttpsURLConnection conn = null; 23 | try { 24 | URL URL_Object = new URL(URL); 25 | conn = (HttpsURLConnection) URL_Object.openConnection(); 26 | conn.setRequestMethod("GET"); 27 | conn.setConnectTimeout(10 * 1000); 28 | final ByteArrayOutputStream output = new ByteArrayOutputStream(); 29 | IOUtils.copy(conn.getInputStream(), output); 30 | return new ByteArrayInputStream(output.toByteArray()); 31 | } catch (IOException e) { 32 | log.error("获取URL输入流发生IO异常",e); 33 | } finally { 34 | if (conn != null) { 35 | conn.disconnect(); 36 | } 37 | } 38 | return null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /sql-file/team.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 阿里云Rds 5 | Source Server Type : MySQL 6 | Source Server Version : 80018 7 | Source Host : rm-bp1b934u5x6g031597o.mysql.rds.aliyuncs.com:3306 8 | Source Schema : robot 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 80018 12 | File Encoding : 65001 13 | 14 | Date: 29/07/2021 14:12:38 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for team 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `team`; 24 | CREATE TABLE `team` ( 25 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `team_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '团标题', 27 | `group_id` bigint(20) NOT NULL COMMENT 'QQ群ID', 28 | `gmt_modify` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', 29 | `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 30 | `delete` int(5) NOT NULL DEFAULT '0' COMMENT '0:否 1:删除', 31 | PRIMARY KEY (`id`) USING BTREE, 32 | KEY `index_gid` (`group_id`) USING BTREE 33 | ) ENGINE=InnoDB AUTO_INCREMENT=76 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='QQ群开团表'; 34 | 35 | SET FOREIGN_KEY_CHECKS = 1; 36 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/helper/ApplicationContextHelper.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.helper; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * spring上下文帮助 10 | */ 11 | @Component 12 | public class ApplicationContextHelper implements ApplicationContextAware { 13 | 14 | private static ApplicationContext applicationContext; 15 | 16 | @Override 17 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 18 | ApplicationContextHelper.applicationContext = applicationContext; 19 | } 20 | 21 | /** 22 | * 获取bean 23 | * 24 | * @param clazz 25 | * @param 26 | * @return 27 | */ 28 | public static T getBean(Class clazz) { 29 | //先判断是否为空 30 | if (applicationContext == null) { 31 | return null; 32 | } 33 | return applicationContext.getBean(clazz); 34 | } 35 | 36 | 37 | public static T getBean(String name, Class clazz) { 38 | if (applicationContext == null) { 39 | return null; 40 | } 41 | return applicationContext.getBean(name, clazz); 42 | } 43 | } -------------------------------------------------------------------------------- /sql-file/inform_relation.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 阿里云Rds 5 | Source Server Type : MySQL 6 | Source Server Version : 80018 7 | Source Host : rm-bp1b934u5x6g031597o.mysql.rds.aliyuncs.com:3306 8 | Source Schema : robot 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 80018 12 | File Encoding : 65001 13 | 14 | Date: 29/07/2021 14:18:05 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for inform_relation 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `inform_relation`; 24 | CREATE TABLE `inform_relation` ( 25 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `post_link_id` bigint(20) NOT NULL COMMENT '帖子链接ID', 27 | `group_id` bigint(20) NOT NULL COMMENT 'QQ群号', 28 | `gmt_modify` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', 29 | `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 30 | `delete` int(5) NOT NULL DEFAULT '0' COMMENT '0:否 1:删除', 31 | PRIMARY KEY (`id`) USING BTREE, 32 | UNIQUE KEY `uniq` (`post_link_id`,`group_id`) USING BTREE 33 | ) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='QQ群链接广播表'; 34 | 35 | SET FOREIGN_KEY_CHECKS = 1; 36 | -------------------------------------------------------------------------------- /Robot-core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Mirai-Robot 7 | com.hyq.robot 8 | ${botVersion} 9 | 10 | 11 | 4.0.0 12 | 13 | Robot-core 14 | 15 | 16 | 17 | 18 | com.hyq.robot 19 | Robot-dao 20 | ${botVersion} 21 | 22 | 23 | com.hyq.robot 24 | Robot-client 25 | ${botVersion} 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-maven-plugin 34 | 35 | exec 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/helper/SendHelper.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.helper; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import net.mamoe.mirai.Bot; 5 | import net.mamoe.mirai.contact.Contact; 6 | import net.mamoe.mirai.contact.Group; 7 | import net.mamoe.mirai.contact.User; 8 | import net.mamoe.mirai.message.data.Message; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author nanke 14 | * @date 2020/4/4 上午2:14 15 | */ 16 | @Slf4j 17 | public class SendHelper { 18 | 19 | /** 20 | * 发送消息 21 | * @param contact 即可以与{@link Bot} 互动的对象. 包含[用户]{@link User}和[群]{@link Group}. 22 | * @param messages 可发送的或从服务器接收的消息. 23 | */ 24 | public static void sendSing(Contact contact, Message messages) { 25 | 26 | contact.sendMessage(messages); 27 | } 28 | 29 | /** 30 | * 多群批发 31 | * @param bot 机器人对象. 一个机器人实例登录一个 QQ 账号 32 | * @param groupIds 群号集合. 需要发送信息的群 33 | * @param messages 消息集合. 消息集合 34 | */ 35 | public static void sendGroupBatch(Bot bot, List groupIds, List messages) { 36 | 37 | messages.forEach(message -> { 38 | for (Long groupId : groupIds) { 39 | try { 40 | Group group = bot.getGroup(groupId); 41 | group.sendMessage(message); 42 | } catch (Exception e) { 43 | log.error("群发送消息发生异常,群ID:{}",groupId,e); 44 | } 45 | } 46 | }); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /sql-file/post_link.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 阿里云Rds 5 | Source Server Type : MySQL 6 | Source Server Version : 80018 7 | Source Host : rm-bp1b934u5x6g031597o.mysql.rds.aliyuncs.com:3306 8 | Source Schema : robot 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 80018 12 | File Encoding : 65001 13 | 14 | Date: 29/07/2021 14:17:49 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for post_link 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `post_link`; 24 | CREATE TABLE `post_link` ( 25 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `area` bigint(20) NOT NULL COMMENT '区服ID', 27 | `area_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '区服务名', 28 | `link_type` bigint(10) NOT NULL COMMENT '帖子链接类型', 29 | `link_url` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '帖子链接地址', 30 | `gmt_modify` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', 31 | `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 32 | `delete` int(5) NOT NULL DEFAULT '0' COMMENT '0:否 1:删除', 33 | PRIMARY KEY (`id`) USING BTREE, 34 | UNIQUE KEY `uniq` (`area`,`link_url`) USING BTREE 35 | ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='帖子链接表'; 36 | 37 | SET FOREIGN_KEY_CHECKS = 1; 38 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/utils/MessageUtil.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.utils; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import java.util.Arrays; 6 | import java.util.List; 7 | import java.util.stream.Collectors; 8 | 9 | /** 10 | * @author nanke 11 | * @date 2020/4/9 下午4:52 12 | */ 13 | public class MessageUtil { 14 | 15 | /** 16 | * 系统分隔符替换 17 | * @param content 18 | * @return 19 | */ 20 | public static String separator(String content) { 21 | return content.replace("?", "?"); 22 | } 23 | 24 | /** 25 | * 关键词分割 26 | * @param content 27 | * @return 28 | */ 29 | public static List split(String content) { 30 | List keyList = Arrays.stream(separator(content).split("\\?")).filter(StringUtils::isNotBlank).collect(Collectors.toList()); 31 | if (keyList.size() <= 1) { 32 | keyList = Arrays.stream(separator(content).split(" ")).filter(StringUtils::isNotBlank).collect(Collectors.toList()); 33 | } 34 | return keyList; 35 | } 36 | 37 | /** 38 | * 获取一级关键词 39 | * @param content 40 | * @return 41 | */ 42 | public static String getKeybyWord(String content, Integer level) { 43 | if (StringUtils.isBlank(content)) { 44 | return ""; 45 | } 46 | List split = split(content); 47 | if (split.isEmpty() || split.size() < level) 48 | return ""; 49 | return split.get(level - 1); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /sql-file/bar_post.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 阿里云Rds 5 | Source Server Type : MySQL 6 | Source Server Version : 80018 7 | Source Host : rm-bp1b934u5x6g031597o.mysql.rds.aliyuncs.com:3306 8 | Source Schema : robot 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 80018 12 | File Encoding : 65001 13 | 14 | Date: 29/07/2021 14:18:13 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for bar_post 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `bar_post`; 24 | CREATE TABLE `bar_post` ( 25 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `floor_id` bigint(20) NOT NULL COMMENT '楼层', 27 | `content` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '楼层内容', 28 | `post_url` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '帖子链接', 29 | `page_no` bigint(20) NOT NULL COMMENT '当前页数', 30 | `gmt_modify` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', 31 | `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 32 | `delete` int(5) NOT NULL DEFAULT '0' COMMENT '0:否 1:删除', 33 | PRIMARY KEY (`id`) USING BTREE, 34 | UNIQUE KEY `uniq` (`post_url`,`floor_id`) USING BTREE 35 | ) ENGINE=InnoDB AUTO_INCREMENT=1528443 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据外观帖'; 36 | 37 | SET FOREIGN_KEY_CHECKS = 1; 38 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/repository/AiChatRepository.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.repository; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | import com.hyq.robot.client.HttpClient; 6 | import lombok.Data; 7 | import org.apache.commons.lang3.StringUtils; 8 | import org.apache.http.message.BasicNameValuePair; 9 | import org.springframework.stereotype.Repository; 10 | 11 | import java.util.Arrays; 12 | 13 | /** 14 | * @author nanke 15 | * @date 2021/5/28 上午11:07 16 | * 致终于来到这里的勇敢的人: 17 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 18 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 19 | */ 20 | @Repository 21 | public class AiChatRepository { 22 | 23 | public static final Gson JSON = new GsonBuilder().create(); 24 | 25 | /** 26 | * 青云客 27 | * @param key 28 | * @return 29 | */ 30 | public String qinYun(String key) { 31 | 32 | BasicNameValuePair var1 = new BasicNameValuePair("key", "free"); 33 | BasicNameValuePair var2 = new BasicNameValuePair("msg", key); 34 | 35 | String s = HttpClient.sendGet("http://api.qingyunke.com/api.php", Arrays.asList(var1, var2)); 36 | if (StringUtils.isBlank(s)) { 37 | return "嗯嗯嗯嗯嗯"; 38 | } 39 | QinYunBody qinYunBody = JSON.fromJson(s, QinYunBody.class); 40 | return qinYunBody.getContent().replace("{br}","\n"); 41 | } 42 | 43 | @Data 44 | public static class QinYunBody { 45 | 46 | /** 47 | * 内容,返回结果中{br}表示换行,请自行替换成需要的代码。 48 | */ 49 | private String content; 50 | } 51 | 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/message/team/CancelKaiTuanFacade.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.message.team; 2 | 3 | import com.hyq.robot.DO.TeamDO; 4 | import com.hyq.robot.dao.TeamDAO; 5 | import com.hyq.robot.enums.EnumKeyWord; 6 | import com.hyq.robot.facade.message.MessageFacade; 7 | import com.hyq.robot.helper.SendHelper; 8 | import net.mamoe.mirai.contact.Contact; 9 | import net.mamoe.mirai.message.data.At; 10 | import net.mamoe.mirai.message.data.Message; 11 | import net.mamoe.mirai.message.data.PlainText; 12 | import org.springframework.stereotype.Component; 13 | 14 | import javax.annotation.Resource; 15 | 16 | /** 17 | * @author nanke 18 | * @date 2020/7/22 下午7:21 19 | */ 20 | @Component 21 | public class CancelKaiTuanFacade extends TeamFacade implements MessageFacade { 22 | 23 | @Resource 24 | private TeamDAO teamDAO; 25 | 26 | @Override 27 | public EnumKeyWord get() { 28 | return EnumKeyWord.GROUP_CANCEL_KAITUAN; 29 | } 30 | 31 | @Override 32 | public void execute(Contact sender, Contact group, Message message) { 33 | 34 | At at = new At(sender.getId()); 35 | 36 | TeamDO teamDO = getTeam(group.getId()); 37 | if (teamDO == null) { 38 | SendHelper.sendSing(group,at.plus(new PlainText("🙅团长被抓"))); 39 | return ; 40 | } 41 | 42 | // 取消团队 43 | TeamDO updateDO = new TeamDO(); 44 | updateDO.setId(teamDO.getId()); 45 | updateDO.setDelete(1); 46 | teamDAO.updateById(updateDO); 47 | SendHelper.sendSing(group,at.plus("👌")); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /sql-file/team_member.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 阿里云Rds 5 | Source Server Type : MySQL 6 | Source Server Version : 80018 7 | Source Host : rm-bp1b934u5x6g031597o.mysql.rds.aliyuncs.com:3306 8 | Source Schema : robot 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 80018 12 | File Encoding : 65001 13 | 14 | Date: 29/07/2021 14:15:24 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for team_member 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `team_member`; 24 | CREATE TABLE `team_member` ( 25 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `team_id` bigint(20) NOT NULL COMMENT '团ID', 27 | `location` bigint(20) NOT NULL COMMENT '队伍位置', 28 | `position` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '职业', 29 | `color` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '填充颜色', 30 | `member_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '角色名', 31 | `qq` bigint(20) NOT NULL COMMENT 'QQ', 32 | `gmt_modify` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', 33 | `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 34 | `delete` int(5) NOT NULL DEFAULT '0' COMMENT '0:否 1:删除', 35 | PRIMARY KEY (`id`) USING BTREE, 36 | KEY `index_tid` (`team_id`,`location`) USING BTREE 37 | ) ENGINE=InnoDB AUTO_INCREMENT=1383 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='QQ群团员表'; 38 | 39 | SET FOREIGN_KEY_CHECKS = 1; 40 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/config/InitBeanConfig.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.config; 2 | 3 | import com.google.common.eventbus.AsyncEventBus; 4 | import com.hyq.robot.constants.CommonConstant; 5 | import com.hyq.robot.listener.GroupListener; 6 | import net.mamoe.mirai.Bot; 7 | import net.mamoe.mirai.BotFactory; 8 | import net.mamoe.mirai.utils.BotConfiguration; 9 | import net.mamoe.mirai.utils.DeviceInfo; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | import javax.annotation.PostConstruct; 14 | import javax.annotation.Resource; 15 | import java.io.File; 16 | import java.util.concurrent.Executors; 17 | 18 | /** 19 | * @author nanke 20 | * @date 2021/1/6 上午10:39 21 | * 致终于来到这里的勇敢的人: 22 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 23 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 24 | */ 25 | @Configuration 26 | public class InitBeanConfig { 27 | 28 | @Resource 29 | private GroupListener groupListener; 30 | @Resource 31 | private Bot bot; 32 | 33 | @Bean 34 | public AsyncEventBus asyncEventBus() { 35 | return new AsyncEventBus(Executors.newFixedThreadPool(5)); 36 | } 37 | 38 | @Bean 39 | public Bot mirai() { 40 | // 机器人 41 | Bot bot = BotFactory.INSTANCE.newBot(CommonConstant.robotQQ, CommonConstant.robotPassword, new BotConfiguration() {{ 42 | // 设备缓存信息 43 | setDeviceInfo(context -> DeviceInfo.from(new File(CommonConstant.robotQQ + "L.json"))); 44 | setProtocol(MiraiProtocol.ANDROID_PAD); 45 | }}); 46 | bot.getEventChannel().registerListenerHost(groupListener); 47 | return bot; 48 | } 49 | 50 | @PostConstruct 51 | public void login() { 52 | bot.login(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/repository/OneEnglishRepository.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.repository; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | import com.hyq.robot.client.HttpClient; 6 | import com.hyq.robot.utils.DateUtil; 7 | import lombok.Data; 8 | import org.apache.commons.lang3.StringUtils; 9 | import org.apache.http.message.BasicNameValuePair; 10 | import org.springframework.stereotype.Repository; 11 | 12 | import java.util.Collections; 13 | import java.util.Date; 14 | 15 | /** 16 | * @author nanke 17 | * @date 2021/6/1 上午10:49 18 | * 致终于来到这里的勇敢的人: 19 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 20 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 21 | */ 22 | @Repository 23 | public class OneEnglishRepository { 24 | 25 | public static final Gson JSON = new GsonBuilder().create(); 26 | 27 | /** 28 | * 爱词霸每日一句 29 | * @return 30 | */ 31 | public ICiBaBody iCiBa() { 32 | 33 | BasicNameValuePair data = new BasicNameValuePair("data", DateUtil.toYMD(new Date())); 34 | String s = HttpClient.sendGet("http://open.iciba.com/dsapi", Collections.singletonList(data)); 35 | if (StringUtils.isBlank(s)) { 36 | s = "{\"content\":\"It isn't the big pleasures that count the most; it's making a great deal out of the little ones.\",\"note\":\"最重要的不是有大快乐,而是能充分享受小快乐。\"}"; 37 | } 38 | ICiBaBody iCiBaBody = JSON.fromJson(s, ICiBaBody.class); 39 | return iCiBaBody; 40 | } 41 | 42 | @Data 43 | public static class ICiBaBody { 44 | 45 | /** 46 | * 英文 47 | */ 48 | private String content; 49 | /** 50 | * 翻译 51 | */ 52 | private String note; 53 | /** 54 | * 图片 55 | */ 56 | private String fenxiang_img; 57 | } 58 | 59 | 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/trans/OpenServiceTrans.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.trans; 2 | 3 | import com.hyq.robot.DO.MainServiceDO; 4 | import com.hyq.robot.DO.ServiceStatusRecordDO; 5 | import com.hyq.robot.dao.MainServiceDAO; 6 | import com.hyq.robot.dao.ServiceStatusRecordDAO; 7 | import com.hyq.robot.enums.EnumOpenStatus; 8 | import org.springframework.stereotype.Component; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import javax.annotation.Resource; 12 | 13 | /** 14 | * @author nanke 15 | * @date 2021/1/6 上午11:18 16 | * 致终于来到这里的勇敢的人: 17 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 18 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 19 | */ 20 | @Component 21 | public class OpenServiceTrans { 22 | 23 | @Resource 24 | private MainServiceDAO mainServiceDAO; 25 | @Resource 26 | private ServiceStatusRecordDAO serviceStatusRecordDAO; 27 | 28 | 29 | /** 30 | * 服务器状态发生变更,进行修改状态与插入变更记录事务操作 31 | * @param mainId 32 | * @param status 33 | * @param serviceName 34 | */ 35 | @Transactional 36 | public void changeStatus(Long mainId, Integer status, String serviceName) { 37 | // 本不该在事务里包装东西的,可以我实在是太懒了 38 | MainServiceDO updateServiceDO = new MainServiceDO(); 39 | updateServiceDO.setMainId(mainId); 40 | // 设置相反服务器状态 41 | updateServiceDO.setOpenStatus(status); 42 | // 记录状态 43 | ServiceStatusRecordDO insertRecordDO = new ServiceStatusRecordDO(); 44 | insertRecordDO.setMainId(mainId); 45 | insertRecordDO.setMainServiceName(serviceName); 46 | insertRecordDO.setOpenStatus(status); 47 | insertRecordDO.setOpenStatusMsg(EnumOpenStatus.get(status).desc); 48 | // 操作 49 | mainServiceDAO.updateById(updateServiceDO); 50 | serviceStatusRecordDAO.insertSelective(insertRecordDO); 51 | 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/message/team/KaiTuanFacade.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.message.team; 2 | 3 | import com.hyq.robot.DO.TeamDO; 4 | import com.hyq.robot.dao.TeamDAO; 5 | import com.hyq.robot.enums.EnumKeyWord; 6 | import com.hyq.robot.facade.message.MessageFacade; 7 | import com.hyq.robot.helper.SendHelper; 8 | import com.hyq.robot.utils.MessageUtil; 9 | import net.mamoe.mirai.contact.Contact; 10 | import net.mamoe.mirai.message.data.At; 11 | import net.mamoe.mirai.message.data.Message; 12 | import net.mamoe.mirai.message.data.PlainText; 13 | import org.apache.commons.lang3.StringUtils; 14 | import org.springframework.stereotype.Component; 15 | 16 | import javax.annotation.Resource; 17 | 18 | 19 | /** 20 | * @author nanke 21 | * @date 2020/7/22 下午4:53 22 | */ 23 | @Component 24 | public class KaiTuanFacade extends TeamFacade implements MessageFacade { 25 | 26 | @Resource 27 | private TeamDAO teamDAO; 28 | 29 | @Override 30 | public EnumKeyWord get() { 31 | return EnumKeyWord.GROUP_KAITUAN; 32 | } 33 | 34 | @Override 35 | public void execute(Contact sender, Contact group, Message message) { 36 | 37 | At at = new At(sender.getId()); 38 | 39 | // 检查群内是否开团 40 | String errorMsg = checkTeam(group.getId()); 41 | if (StringUtils.isBlank(errorMsg)) { 42 | SendHelper.sendSing(group,at.plus("🙅不准再开")); 43 | return ; 44 | } 45 | 46 | String content = message.contentToString(); 47 | String teamName = MessageUtil.getKeybyWord(content, 2); 48 | if (StringUtils.isBlank(teamName)) { 49 | SendHelper.sendSing(group,at.plus(new PlainText("🙅暗号错误"))); 50 | return ; 51 | } 52 | 53 | TeamDO insetDO = new TeamDO(); 54 | insetDO.setGroupId(group.getId()); 55 | insetDO.setTeamName(teamName); 56 | teamDAO.insertSelective(insetDO); 57 | 58 | SendHelper.sendSing(group,at.plus("👌")); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /Robot-dao/src/main/resources/mapper/SubServiceDAO.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | `SUB_ID`,`MAIN_ID`,`SUB_SERVICE_NAME`,`GMT_MODIFY`,`GMT_CREATE`,`DELETE` 17 | 18 | 19 | 20 | 21 | `SUB_ID` = #{subId,jdbcType=BIGINT} 22 | AND `MAIN_ID` = #{mainId,jdbcType=BIGINT} 23 | AND `SUB_SERVICE_NAME` LIKE concat('%',#{subServiceName,jdbcType=VARCHAR},'%') 24 | 25 | AND `DELETE` = #{delete,jdbcType=INTEGER} 26 | AND `DELETE` = 0 27 | 28 | 29 | 30 | 31 | 36 | 37 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/message/team/TeamFacade.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.message.team; 2 | 3 | import com.hyq.robot.DO.TeamDO; 4 | import com.hyq.robot.DO.TeamMemberDO; 5 | import com.hyq.robot.dao.TeamDAO; 6 | import com.hyq.robot.dao.TeamMemberDAO; 7 | import com.hyq.robot.query.TeamMemberQuery; 8 | import com.hyq.robot.query.TeamQuery; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.util.CollectionUtils; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | 15 | /** 16 | * @author nanke 17 | * @date 2021/5/28 上午11:27 18 | * 致终于来到这里的勇敢的人: 19 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 20 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 21 | */ 22 | @Component 23 | public class TeamFacade { 24 | 25 | @Resource 26 | private TeamDAO teamDAO; 27 | @Resource 28 | private TeamMemberDAO teamMemberDAO; 29 | 30 | /** 31 | * 检查团队是否存在 32 | * @param groupId 33 | * @return 34 | */ 35 | public String checkTeam(Long groupId) { 36 | TeamQuery query = new TeamQuery(); 37 | query.setGroupId(groupId); 38 | List teamDOS = teamDAO.queryByCondition(query); 39 | if (CollectionUtils.isEmpty(teamDOS)) { 40 | return "🙅团长被抓"; 41 | } 42 | return null; 43 | } 44 | 45 | /** 46 | * 获取第一个团队 47 | * @param groupId 48 | * @return 49 | */ 50 | public TeamDO getTeam(Long groupId) { 51 | TeamQuery query = new TeamQuery(); 52 | query.setGroupId(groupId); 53 | List teamDOS = teamDAO.queryByCondition(query); 54 | return CollectionUtils.isEmpty(teamDOS) ? null : teamDOS.get(0); 55 | } 56 | 57 | /** 58 | * 获取团队位置成员 59 | * @param teamId 60 | * @return 61 | */ 62 | public List getTeamMember(Long teamId, Long location) { 63 | TeamMemberQuery memberQuery = new TeamMemberQuery(); 64 | memberQuery.setTeamId(teamId); 65 | memberQuery.setLocation(location); 66 | return teamMemberDAO.queryByCondition(memberQuery); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /Robot-dao/src/main/resources/mapper/BarPostDAO.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | `ID` , 19 | `FLOOR_ID` , 20 | `CONTENT` , 21 | `POST_URL` , 22 | `PAGE_NO` , 23 | `GMT_MODIFY` , 24 | `GMT_CREATE` , 25 | `DELETE` 26 | 27 | 28 | 29 | INSERT INTO 30 | `bar_post` 31 | ( 32 | `FLOOR_ID`, 33 | `CONTENT`, 34 | `POST_URL`, 35 | `PAGE_NO` 36 | ) VALUES 37 | 38 | ( 39 | #{item.floorId,jdbcType=BIGINT}, 40 | #{item.content,jdbcType=VARCHAR}, 41 | #{item.postUrl,jdbcType=VARCHAR}, 42 | #{item.pageNo,jdbcType=BIGINT} 43 | ) 44 | 45 | 46 | 47 | 48 | 49 | AND `POST_URL` = #{postUrl,jdbcType=VARCHAR} 50 | 51 | AND `DELETE` = #{delete,jdbcType=INTEGER} 52 | AND `DELETE` = 0 53 | 54 | 55 | 56 | 57 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /Robot-client/src/main/java/com/hyq/robot/client/CreeperClient.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.client; 2 | 3 | import com.gargoylesoftware.htmlunit.BrowserVersion; 4 | import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController; 5 | import com.gargoylesoftware.htmlunit.ProxyConfig; 6 | import com.gargoylesoftware.htmlunit.WebClient; 7 | import com.gargoylesoftware.htmlunit.html.HtmlPage; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.commons.lang3.StringUtils; 10 | import org.jsoup.Jsoup; 11 | import org.jsoup.nodes.Document; 12 | 13 | 14 | /** 15 | * @author nanke 16 | * @date 2020/3/31 上午12:30 17 | */ 18 | @Slf4j 19 | public class CreeperClient { 20 | 21 | public static Document getHtmlDocument(String url,String proxyHost,Integer proxyPort) { 22 | 23 | WebClient webClient = new WebClient(BrowserVersion.CHROME); 24 | 25 | if (StringUtils.isNotBlank(proxyHost) && proxyPort != null) { 26 | ProxyConfig proxyConfig = new ProxyConfig(); 27 | proxyConfig.setProxyHost(proxyHost); 28 | proxyConfig.setProxyPort(proxyPort); 29 | webClient.getOptions().setProxyConfig(proxyConfig); 30 | } 31 | // 超时时间 32 | webClient.getOptions().setTimeout(3000); 33 | // JS执行出错的时是否抛出异常 34 | webClient.getOptions().setThrowExceptionOnScriptError(false); 35 | // HTTP的状态非200时是否抛出异常 36 | webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); 37 | webClient.getOptions().setActiveXNative(false); 38 | // 是否启用CSS 39 | webClient.getOptions().setCssEnabled(false); 40 | // 是否启用JS 41 | webClient.getOptions().setJavaScriptEnabled(false); 42 | // 设置支持AJAX 43 | webClient.setAjaxController(new NicelyResynchronizingAjaxController()); 44 | HtmlPage page = null; 45 | try { 46 | // 尝试加载网页 47 | page = webClient.getPage(url); 48 | } catch (Exception e) { 49 | log.error("爬虫失败,URL地址:{}",url,e); 50 | } finally { 51 | webClient.close(); 52 | } 53 | webClient.waitForBackgroundJavaScript(30000); 54 | // 直接将加载完成的页面转换成xml格式的字符串 55 | return page == null ? null : Jsoup.parse(page.asXml()); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Robot-dao/src/main/resources/mapper/TeamDAO.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | `ID` , 17 | `TEAM_NAME` , 18 | `GROUP_ID` , 19 | `GMT_MODIFY` , 20 | `GMT_CREATE` , 21 | `DELETE` 22 | 23 | 24 | 25 | INSERT INTO 26 | `team` 27 | 28 | `TEAM_NAME`, 29 | `GROUP_ID`, 30 | 31 | 32 | #{teamName,jdbcType=VARCHAR}, 33 | #{groupId,jdbcType=BIGINT}, 34 | 35 | 36 | 37 | 38 | UPDATE `team` 39 | SET `DELETE` = #{delete,jdbcType=INTEGER} 40 | WHERE `ID` = #{id,jdbcType=BIGINT} 41 | 42 | 43 | 44 | 45 | `ID`=#{id,jdbcType=BIGINT} 46 | AND `TEAM_NAME`=#{teamName,jdbcType=VARCHAR} 47 | AND `GROUP_ID`=#{groupId,jdbcType=BIGINT} 48 | 49 | AND `DELETE` = #{delete,jdbcType=INTEGER} 50 | AND `DELETE` = 0 51 | 52 | 53 | 54 | 55 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/autojob/GoodMorningTask.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.autojob; 2 | 3 | import com.hyq.robot.helper.ApplicationContextHelper; 4 | import com.hyq.robot.helper.SendHelper; 5 | import com.hyq.robot.repository.OneEnglishRepository; 6 | import com.hyq.robot.utils.DateUtil; 7 | import com.hyq.robot.utils.NetworkUtil; 8 | import net.mamoe.mirai.Bot; 9 | import net.mamoe.mirai.contact.ContactList; 10 | import net.mamoe.mirai.contact.Group; 11 | import net.mamoe.mirai.message.data.Image; 12 | import net.mamoe.mirai.message.data.MessageChain; 13 | import net.mamoe.mirai.message.data.PlainText; 14 | import net.mamoe.mirai.utils.ExternalResource; 15 | import org.apache.commons.lang3.StringUtils; 16 | import org.springframework.context.annotation.Configuration; 17 | import org.springframework.scheduling.annotation.EnableScheduling; 18 | import org.springframework.scheduling.annotation.Scheduled; 19 | 20 | import javax.annotation.Resource; 21 | import java.io.InputStream; 22 | import java.util.Date; 23 | 24 | /** 25 | * @author nanke 26 | * @date 2020/4/5 上午12:14 27 | */ 28 | @Configuration 29 | @EnableScheduling 30 | public class GoodMorningTask { 31 | 32 | @Resource 33 | private OneEnglishRepository oneEnglishRepository; 34 | 35 | @Scheduled(cron = "0 30 8 * * ? ") 36 | public void task() { 37 | 38 | OneEnglishRepository.ICiBaBody iCiBaBody = oneEnglishRepository.iCiBa(); 39 | String content = iCiBaBody.getContent(); 40 | String note = iCiBaBody.getNote(); 41 | 42 | PlainText plainText = new PlainText("早安,今天是" + DateUtil.toYMD(new Date()) + "\n\n" + "●每日一句:\n" + content + "\n" + note + "\n"); 43 | MessageChain plus = null; 44 | 45 | ContactList groups = ApplicationContextHelper.getBean(Bot.class).getGroups(); 46 | for (Group e : groups) { 47 | 48 | if (StringUtils.isNotBlank(iCiBaBody.getFenxiang_img())) { 49 | InputStream inputStream = NetworkUtil.getInputStream(iCiBaBody.getFenxiang_img()); 50 | if (inputStream != null) { 51 | Image image = ExternalResource.uploadAsImage(inputStream, e); 52 | plus = plainText.plus(image); 53 | } 54 | } else { 55 | plus = plainText.plus(new PlainText("【警告】发生了一些预期之外的问题")); 56 | } 57 | SendHelper.sendSing(e,plus); 58 | } 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/enums/EnumKeyWord.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.enums; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | 7 | /** 8 | * @author nanke 9 | * @date 2020/4/4 上午2:20 10 | */ 11 | public enum EnumKeyWord { 12 | /** 13 | * 查询?双梦?踏云 14 | */ 15 | GROUP_SELECT(1,2,"查询"), 16 | /** 17 | * 副本排单助手 18 | */ 19 | GROUP_KAITUAN(1,6,"开团"), 20 | GROUP_CANCEL_KAITUAN(1,7,"取消开团"), 21 | GROUP_SEE_KAITUAN(1,8,"查看团队"), 22 | GROUP_BAOMING(1,9,"报名"), 23 | GROUP_JIAOHUAN(1,10,"交换"), 24 | GROUP_CANCEL_BAOMING(1,11,"取消报名"), 25 | /** 26 | * 开服监控 27 | */ 28 | GROUP_KFJK(1,14,"开服监控"), 29 | GROUP_QXJK(1,15,"取消监控"), 30 | GROUP_KFCX(1,16,"开服查询"), 31 | /** 32 | * 私聊口令 33 | */ 34 | PRIVATE_DEFAULT(2,1,""), 35 | PRIVATE_SELECT(2,2,"查询"), 36 | ; 37 | 38 | /** 39 | * 类型 40 | * 1\群聊 2\私聊 41 | */ 42 | public Integer type; 43 | /** 44 | * 关键码 45 | */ 46 | public Integer code; 47 | /** 48 | * 关键词 49 | */ 50 | public String keyWord; 51 | 52 | EnumKeyWord(Integer type, Integer code, String keyWord) { 53 | this.type = type; 54 | this.code = code; 55 | this.keyWord = keyWord; 56 | } 57 | 58 | /** 59 | * 群聊关键词匹配 60 | * @param keyWord 61 | * @return 62 | */ 63 | public static EnumKeyWord groupFind(String keyWord) { 64 | 65 | List collect = Arrays.stream(EnumKeyWord.values()).filter(e -> e.type.equals(1)).collect(Collectors.toList()); 66 | for (EnumKeyWord value : collect) { 67 | // if (keyWord.matches(value.keyWord + ".*")) { 68 | // return value; 69 | // } 70 | if (keyWord.equals(value.keyWord)) { 71 | return value; 72 | } 73 | } 74 | return null; 75 | } 76 | 77 | /** 78 | * 私聊关键词匹配 79 | * @param keyWord 80 | * @return 81 | */ 82 | public static EnumKeyWord privateFind(String keyWord) { 83 | 84 | List collect = Arrays.stream(EnumKeyWord.values()).filter(e -> e.type.equals(2)).collect(Collectors.toList()); 85 | for (EnumKeyWord value : collect) { 86 | if (keyWord.matches(value.keyWord + ".*")) 87 | return value; 88 | } 89 | return EnumKeyWord.PRIVATE_DEFAULT; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Robot-dao/src/main/resources/mapper/MainServiceDAO.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | `MAIN_ID`,`IP_ADDRESS`,`PORT`,`AREA_NAME`,`MAIN_SERVICE_NAME`,`OPEN_STATUS`, 20 | `GMT_MODIFY`,`GMT_CREATE`,`DELETE` 21 | 22 | 23 | 24 | UPDATE `main_service` 25 | 26 | `OPEN_STATUS`=#{openStatus,jdbcType=INTEGER} 27 | 28 | WHERE `MAIN_ID` = #{mainId,jdbcType=BIGINT} 29 | 30 | 31 | 32 | 33 | `MAIN_ID`=#{mainId,jdbcType=BIGINT} 34 | AND `OPEN_STATUS`=#{openStatus,jdbcType=INTEGER} 35 | 36 | AND `DELETE` = #{delete,jdbcType=INTEGER} 37 | AND `DELETE` = 0 38 | 39 | 40 | 41 | 42 | 47 | 48 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/message/team/ChaKanTuanDuiFacade.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.message.team; 2 | 3 | import com.hyq.robot.DO.TeamDO; 4 | import com.hyq.robot.DO.TeamMemberDO; 5 | import com.hyq.robot.enums.EnumKeyWord; 6 | import com.hyq.robot.facade.message.MessageFacade; 7 | import com.hyq.robot.helper.SendHelper; 8 | import com.hyq.robot.utils.GroupMemberUtil; 9 | import gui.ava.html.image.generator.HtmlImageGenerator; 10 | import net.mamoe.mirai.contact.Contact; 11 | import net.mamoe.mirai.message.data.At; 12 | import net.mamoe.mirai.message.data.Image; 13 | import net.mamoe.mirai.message.data.Message; 14 | import net.mamoe.mirai.message.data.PlainText; 15 | import net.mamoe.mirai.utils.ExternalResource; 16 | import org.apache.commons.lang3.StringUtils; 17 | import org.springframework.stereotype.Component; 18 | 19 | import javax.imageio.ImageIO; 20 | import java.io.ByteArrayOutputStream; 21 | import java.io.IOException; 22 | import java.util.List; 23 | 24 | /** 25 | * @author nanke 26 | * @date 2020/7/22 下午11:03 27 | */ 28 | @Component 29 | public class ChaKanTuanDuiFacade extends TeamFacade implements MessageFacade { 30 | 31 | @Override 32 | public EnumKeyWord get() { 33 | return EnumKeyWord.GROUP_SEE_KAITUAN; 34 | } 35 | 36 | @Override 37 | public void execute(Contact sender, Contact group, Message message) throws IOException { 38 | 39 | At at = new At(sender.getId()); 40 | // 检查群内是否开团 41 | String errorMsg = checkTeam(group.getId()); 42 | if (StringUtils.isNotBlank(errorMsg)) { 43 | SendHelper.sendSing(group,at.plus(errorMsg)); 44 | return ; 45 | } 46 | 47 | TeamDO teamDO = getTeam(group.getId()); 48 | List teamMemberDOS = getTeamMember(teamDO.getId(),null); 49 | // 渲染HTML 50 | String htmlStr = GroupMemberUtil.replaceMember(teamDO.getTeamName(), teamMemberDOS); 51 | HtmlImageGenerator generator = new HtmlImageGenerator(); 52 | generator.loadHtml(GroupMemberUtil.replaceInit("",htmlStr)); 53 | 54 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 55 | ImageIO.write(generator.getBufferedImage(),"png",out); 56 | 57 | byte[] bytes = out.toByteArray(); 58 | 59 | ExternalResource externalResource = ExternalResource.create(bytes); 60 | Image image = group.uploadImage(externalResource); 61 | SendHelper.sendSing(group,new PlainText("团队详情:\n").plus(image)); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Robot-dao/src/main/resources/mapper/InformRelationDAO.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | `ID` , 17 | `POST_LINK_ID` , 18 | `GROUP_ID` , 19 | `GMT_MODIFY` , 20 | `GMT_CREATE` , 21 | `DELETE` 22 | 23 | 24 | 25 | INSERT INTO `inform_relation` 26 | 27 | `ID`, 28 | `POST_LINK_ID`, 29 | `GROUP_ID`, 30 | `GMT_MODIFY`, 31 | `GMT_CREATE`, 32 | `DELETE` 33 | 34 | 35 | #{id,jdbcType=BIGINT}, 36 | #{postLinkId,jdbcType=BIGINT}, 37 | #{groupId,jdbcType=BIGINT}, 38 | #{gmtModify,jdbcType=TIMESTAMP}, 39 | #{gmtCreate,jdbcType=TIMESTAMP}, 40 | #{delete,jdbcType=INTEGER} 41 | 42 | 43 | 44 | 45 | 46 | `ID`=#{id,jdbcType=BIGINT} 47 | AND `POST_LINK_ID`=#{postLinkId,jdbcType=BIGINT} 48 | AND `GROUP_ID`=#{groupId,jdbcType=BIGINT} 49 | 50 | AND `DELETE` = #{delete,jdbcType=INTEGER} 51 | AND `DELETE` = 0 52 | 53 | 54 | 55 | 56 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/message/team/CancelBaoMingFacade.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.message.team; 2 | 3 | import com.hyq.robot.DO.TeamDO; 4 | import com.hyq.robot.DO.TeamMemberDO; 5 | import com.hyq.robot.dao.TeamMemberDAO; 6 | import com.hyq.robot.enums.EnumKeyWord; 7 | import com.hyq.robot.facade.message.MessageFacade; 8 | import com.hyq.robot.helper.SendHelper; 9 | import com.hyq.robot.utils.GroupMemberUtil; 10 | import com.hyq.robot.utils.MessageUtil; 11 | import net.mamoe.mirai.contact.Contact; 12 | import net.mamoe.mirai.message.data.At; 13 | import net.mamoe.mirai.message.data.Message; 14 | import org.apache.commons.lang3.StringUtils; 15 | import org.springframework.stereotype.Component; 16 | import org.springframework.util.CollectionUtils; 17 | 18 | import javax.annotation.Resource; 19 | import java.util.List; 20 | 21 | /** 22 | * @author nanke 23 | * @date 2020/7/22 下午11:14 24 | */ 25 | @Component 26 | public class CancelBaoMingFacade extends TeamFacade implements MessageFacade { 27 | 28 | @Resource 29 | private TeamMemberDAO teamMemberDAO; 30 | 31 | @Override 32 | public EnumKeyWord get() { 33 | return EnumKeyWord.GROUP_CANCEL_BAOMING; 34 | } 35 | 36 | @Override 37 | public void execute(Contact sender, Contact group, Message message) { 38 | 39 | At at = new At(sender.getId()); 40 | String content = message.contentToString(); 41 | long groupId = group.getId(); 42 | 43 | // 检查群内是否开团 44 | String errorMsg = checkTeam(groupId); 45 | if (StringUtils.isNotBlank(errorMsg)) { 46 | SendHelper.sendSing(group,at.plus(errorMsg)); 47 | return ; 48 | } 49 | // 获取位置 50 | Long location = null; 51 | String locationStr = MessageUtil.getKeybyWord(content, 2); 52 | try { 53 | location = Long.valueOf(locationStr); 54 | } catch (Exception e) { 55 | SendHelper.sendSing(group,at.plus("🙅暗号错误")); 56 | return ; 57 | } 58 | // 位置合法性 59 | if (!GroupMemberUtil.checkLocation(location)) { 60 | SendHelper.sendSing(group,at.plus("🙅暗号错误")); 61 | return ; 62 | } 63 | // 获取团队成员 64 | TeamDO teamDO = getTeam(groupId); 65 | List teamMemberDOS = getTeamMember(teamDO.getId(),location); 66 | // 位置是否有人 67 | if (CollectionUtils.isEmpty(teamMemberDOS)) { 68 | SendHelper.sendSing(group,at.plus("🙅暗号错误")); 69 | return ; 70 | } 71 | // 取消 72 | TeamMemberDO updateDO = new TeamMemberDO(); 73 | updateDO.setId(teamMemberDOS.get(0).getId()); 74 | updateDO.setDelete(1); 75 | teamMemberDAO.updateById(updateDO); 76 | SendHelper.sendSing(group,at.plus("👌")); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Robot-dao/src/main/resources/mapper/OpenServiceSubscribeDAO.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | `ID`,`MAIN_ID`,`QQ`,`GROUP_ID`,`GMT_MODIFY`,`GMT_CREATE`,`DELETE` 18 | 19 | 20 | 21 | INSERT INTO `open_service_subscribe` 22 | 23 | `MAIN_ID`, 24 | `QQ`, 25 | `GROUP_ID`, 26 | 27 | 28 | #{mainId,jdbcType=BIGINT}, 29 | #{qq,jdbcType=BIGINT}, 30 | #{groupId,jdbcType=BIGINT}, 31 | 32 | 33 | 34 | 35 | UPDATE `open_service_subscribe` 36 | 37 | `DELETE`=#{delete,jdbcType=INTEGER} 38 | 39 | WHERE `ID` = #{id,jdbcType=BIGINT} 40 | 41 | 42 | 43 | 44 | AND `MAIN_ID`=#{mainId,jdbcType=BIGINT} 45 | AND `GROUP_ID`=#{groupId,jdbcType=BIGINT} 46 | 47 | AND `DELETE` = #{delete,jdbcType=INTEGER} 48 | AND `DELETE` = 0 49 | 50 | 51 | 52 | 53 | 58 | 59 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/enums/EnumPosition.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.enums; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | /** 6 | * @author nanke 7 | * @date 2020/7/22 下午8:28 8 | * 9 | * 报名职业枚举 10 | */ 11 | public enum EnumPosition { 12 | 13 | YANTIAN("衍天 演员","https://img.jx3box.com/image/xf/10615.png","内功"), 14 | LINXUE("凌雪 凌血","https://img.jx3box.com/image/xf/10585.png","外功"), 15 | PENGLAI("蓬莱","https://img.jx3box.com/image/xf/10533.png","外功"), 16 | BADAO("霸刀","https://img.jx3box.com/image/xf/10464.png","外功"), 17 | CHANGGE("莫问 长歌","https://img.jx3box.com/image/xf/10447.png","内功"), 18 | NAIGE("奶歌 奶鸽 相知","https://img.jx3box.com/image/xf/10448.png","奶妈"), 19 | FENSHAN("分山 苍云 岔劲 分山劲","https://img.jx3box.com/image/xf/10390.png","外功"), 20 | TIEGU("铁骨","https://img.jx3box.com/image/xf/10389.png","坦克"), 21 | GAIBANG("丐帮","https://img.jx3box.com/image/xf/10268.png","外功"), 22 | FENGYING("焚影 明教","https://img.jx3box.com/image/xf/10242.png","内功"), 23 | MINGZUN("明尊","https://img.jx3box.com/image/xf/10243.png","坦克"), 24 | TIANLUO("田螺 天罗","https://img.jx3box.com/image/xf/10225.png","内功"), 25 | JINGYU("惊羽 唐门","https://img.jx3box.com/image/xf/10224.png","外功"), 26 | DUJING("毒经 五毒","https://img.jx3box.com/image/xf/10175.png","内功"), 27 | NAIDU("奶毒 补天","https://img.jx3box.com/image/xf/10176.png","奶妈"), 28 | CANGJIAN("藏剑","https://img.jx3box.com/image/xf/10144.png","外功"), 29 | AOXUE("傲血 傲雪","https://img.jx3box.com/image/xf/10026.png","外功"), 30 | TIELAO("铁牢","https://img.jx3box.com/image/xf/10062.png","坦克"), 31 | JIANCHUN("剑纯 备胎","https://img.jx3box.com/image/xf/10015.png","外功"), 32 | QICHUN("气纯","https://img.jx3box.com/image/xf/10014.png","内功"), 33 | BINGXIN("冰心 法王","https://img.jx3box.com/image/xf/10081.png","内功"), 34 | NAIXIU("奶秀","https://img.jx3box.com/image/xf/10080.png","奶妈"), 35 | HUAJIAN("花间","https://img.jx3box.com/image/xf/10021.png","内功"), 36 | NAIHUA("奶花 离经","https://img.jx3box.com/image/xf/10028.png","奶妈"), 37 | YIJING("易筋 和尚","https://img.jx3box.com/image/xf/10003.png","内功"), 38 | XISUI("洗髓","https://img.jx3box.com/image/xf/10002.png","坦克"), 39 | HAOLAI("号来","https://img.jx3box.com/image/xf/0.png",""), 40 | ; 41 | 42 | /** 43 | * 职业 44 | */ 45 | public String position; 46 | /** 47 | * 职业图标 48 | */ 49 | public String color; 50 | /** 51 | * 职业类型 52 | */ 53 | public String type; 54 | 55 | EnumPosition(String position, String color, String type) { 56 | this.position = position; 57 | this.color = color; 58 | this.type = type; 59 | } 60 | 61 | public static EnumPosition get(String position) { 62 | 63 | if (StringUtils.isBlank(position)) { 64 | return null; 65 | } 66 | 67 | for (EnumPosition value : EnumPosition.values()) { 68 | if (value.position.contains(position)) { 69 | return value; 70 | } 71 | } 72 | return null; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Robot-dao/src/main/java/com/hyq/robot/config/DataSourceConfig.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.config; 2 | 3 | import com.alibaba.druid.pool.DruidDataSource; 4 | import org.apache.ibatis.session.SqlSessionFactory; 5 | import org.mybatis.spring.SqlSessionFactoryBean; 6 | import org.mybatis.spring.annotation.MapperScan; 7 | import org.springframework.beans.factory.annotation.Qualifier; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; 11 | import org.springframework.jdbc.datasource.DataSourceTransactionManager; 12 | import org.springframework.transaction.support.TransactionTemplate; 13 | 14 | import static org.springframework.transaction.TransactionDefinition.ISOLATION_DEFAULT; 15 | 16 | /** 17 | * @author nanke 18 | * @date 2020/4/4 下午2:35 19 | */ 20 | @Configuration 21 | @MapperScan(basePackages = {FilePathConstant.DAO_PACKAGE},sqlSessionFactoryRef = "sessionFactory") 22 | public class DataSourceConfig { 23 | 24 | @javax.annotation.Resource 25 | private DataSourceProperty dataSourceProperty; 26 | 27 | /********************* 28 | * * 29 | * 数据源 * 30 | * * 31 | *********************/ 32 | 33 | @Bean(name = "dataSource") 34 | public DruidDataSource getDataSource() { 35 | 36 | DruidDataSource dataSource = new DruidDataSource(); 37 | dataSource.setDriverClassName(dataSourceProperty.getDriverClass()); 38 | dataSource.setUrl(dataSourceProperty.getUrl()); 39 | dataSource.setUsername(dataSourceProperty.getName()); 40 | dataSource.setPassword(dataSourceProperty.getPassWord()); 41 | return dataSource; 42 | } 43 | 44 | /********************* 45 | * * 46 | * 事务源 * 47 | * * 48 | *********************/ 49 | 50 | @Bean(name = "transactionTemplate") 51 | public TransactionTemplate teambuyTransactionTemplate(@Qualifier("dataSource") DruidDataSource dataSource) { 52 | 53 | DataSourceTransactionManager transcationManager = new DataSourceTransactionManager(dataSource); 54 | TransactionTemplate transactionTemplate = new TransactionTemplate(); 55 | transactionTemplate.setIsolationLevel(ISOLATION_DEFAULT); 56 | transactionTemplate.setTimeout(10); 57 | transactionTemplate.setTransactionManager(transcationManager); 58 | return transactionTemplate; 59 | } 60 | 61 | @Bean("sessionFactory") 62 | public SqlSessionFactory sessionFactory(@Qualifier("dataSource") DruidDataSource dataSource) throws Exception { 63 | 64 | final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); 65 | sessionFactory.setDataSource(dataSource); 66 | sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(FilePathConstant.MAPPER_PACKAGE)); 67 | return sessionFactory.getObject(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/utils/TieBaUtil.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.utils; 2 | 3 | import com.hyq.robot.DO.BarPostDO; 4 | import com.hyq.robot.client.CreeperClient; 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.jsoup.nodes.Document; 7 | import org.jsoup.nodes.Element; 8 | import org.springframework.util.CollectionUtils; 9 | 10 | import java.util.*; 11 | import java.util.regex.Pattern; 12 | import java.util.stream.Collectors; 13 | 14 | /** 15 | * @author nanke 16 | * @date 2020/7/14 下午6:54 17 | */ 18 | public class TieBaUtil { 19 | 20 | /** 21 | * 获取帖子总页数 22 | * @param url 23 | * @return 24 | */ 25 | public static Long queryPageNo(String url, String host, Integer port) { 26 | 27 | Document document = CreeperClient.getHtmlDocument(url,host,port); 28 | List select = document.select("span[class=\"red\"]"); 29 | Set set = new HashSet<>(); 30 | for (Element element : select) { 31 | try { 32 | set.add(Long.valueOf(element.text())); 33 | } catch (Exception e) {} 34 | } 35 | 36 | Long pageNo = 1L; 37 | if (set.contains(0L) || set.contains(1L)) 38 | return pageNo; 39 | return set.stream().sorted().limit(1).collect(Collectors.toList()).get(0); 40 | } 41 | 42 | /** 43 | * 获取帖子数据 44 | * @param url 45 | * @return 46 | */ 47 | public static Map> handle(String url, String host, Integer port) { 48 | // 进行爬取并接收数据 49 | Document document = CreeperClient.getHtmlDocument(url,host,port); 50 | // 获取帖子中用户回复的内容 51 | List contentList = document.select("div[id~=post_content_(-?\\d*)(\\.\\d+)?]"); 52 | List floorList = document.select("span[class=tail-info]"); 53 | 54 | List contents = contentList.stream().map(Element::text).collect(Collectors.toList()); 55 | List floors = floorList.stream().filter(element -> Pattern.compile("楼").matcher(String.valueOf(element)).find()) 56 | .map(e -> Long.valueOf(e.text().replace("楼", ""))).collect(Collectors.toList()); 57 | 58 | Map> map = new HashMap<>(); 59 | map.put("contentList",contents); 60 | map.put("floorList",floors); 61 | return map; 62 | } 63 | 64 | /** 65 | * 查询 66 | * @param content 67 | * @return 68 | */ 69 | public static boolean messageFilter(String content) { 70 | 71 | if (StringUtils.isBlank(content) 72 | || content.length() > 128 || content.contains("代充") || content.contains("呆充") 73 | || content.contains("杂货铺") || content.contains("招募") || content.contains("经验+3") 74 | || content.contains("代售") || content.contains("扶摇九天") || content.contains("桃宝") 75 | ) { 76 | return false; 77 | } 78 | if (!content.contains("出") && !content.contains("收")) { 79 | return false; 80 | } 81 | return true; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Robot-dao/src/main/resources/mapper/ServiceStatusRecordDAO.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | `ID`,`MAIN_ID`,`MAIN_SERVICE_NAME`,`OPEN_STATUS`,`OPEN_STATUS_MSG`,`GMT_MODIFY`, 19 | `GMT_CREATE`,`DELETE` 20 | 21 | 22 | 23 | INSERT INTO `service_status_record` 24 | 25 | `MAIN_ID`, 26 | `MAIN_SERVICE_NAME`, 27 | `OPEN_STATUS`, 28 | `OPEN_STATUS_MSG` 29 | 30 | 31 | #{mainId,jdbcType=BIGINT}, 32 | #{mainServiceName,jdbcType=VARCHAR}, 33 | #{openStatus,jdbcType=INTEGER}, 34 | #{openStatusMsg,jdbcType=VARCHAR} 35 | 36 | 37 | 38 | 39 | 40 | AND `MAIN_ID` = #{mainId,jdbcType=BIGINT} 41 | AND `OPEN_STATUS` = #{openStatus,jdbcType=INTEGER} 42 | 43 | AND `DELETE` = #{delete,jdbcType=INTEGER} 44 | AND `DELETE` = 0 45 | 46 | 47 | 48 | 49 | 55 | 56 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Robot-dao/src/main/resources/mapper/PostLinkDAO.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | `ID` , 19 | `AREA` , 20 | `AREA_NAME` , 21 | `LINK_TYPE` , 22 | `LINK_URL` , 23 | `GMT_MODIFY` , 24 | `GMT_CREATE` , 25 | `DELETE` 26 | 27 | 28 | 29 | INSERT INTO `post_link` 30 | 31 | `ID`, 32 | `AREA`, 33 | `AREA_NAME`, 34 | `LINK_TYPE`, 35 | `LINK_URL`, 36 | `GMT_MODIFY`, 37 | `GMT_CREATE`, 38 | `DELETE` 39 | 40 | 41 | #{id,jdbcType=BIGINT}, 42 | #{area,jdbcType=BIGINT}, 43 | #{areaName,jdbcType=VARCHAR}, 44 | #{linkType,jdbcType=BIGINT}, 45 | #{linkUrl,jdbcType=VARCHAR}, 46 | #{gmtModify,jdbcType=TIMESTAMP}, 47 | #{gmtCreate,jdbcType=TIMESTAMP}, 48 | #{delete,jdbcType=INTEGER} 49 | 50 | 51 | 52 | 53 | 54 | `ID`=#{id,jdbcType=BIGINT} 55 | AND `AREA`=#{area,jdbcType=BIGINT} 56 | AND `AREA_NAME`=#{areaName,jdbcType=VARCHAR} 57 | AND `LINK_TYPE`=#{linkType,jdbcType=BIGINT} 58 | AND `LINK_URL`=#{linkUrl,jdbcType=VARCHAR} 59 | 60 | AND `DELETE` = #{delete,jdbcType=INTEGER} 61 | AND `DELETE` = 0 62 | 63 | 64 | 65 | 66 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /Robot-dao/src/main/resources/mapper/TeamMemberDAO.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | `ID` , 21 | `TEAM_ID` , 22 | `LOCATION` , 23 | `POSITION` , 24 | `COLOR` , 25 | `MEMBER_NAME` , 26 | `QQ` , 27 | `GMT_MODIFY` , 28 | `GMT_CREATE` , 29 | `DELETE` 30 | 31 | 32 | 33 | INSERT INTO 34 | `team_member` 35 | 36 | `TEAM_ID`, 37 | `LOCATION`, 38 | `POSITION`, 39 | `COLOR`, 40 | `MEMBER_NAME`, 41 | `QQ`, 42 | 43 | 44 | #{teamId,jdbcType=BIGINT}, 45 | #{location,jdbcType=BIGINT}, 46 | #{position,jdbcType=VARCHAR}, 47 | #{color,jdbcType=VARCHAR}, 48 | #{memberName,jdbcType=VARCHAR}, 49 | #{qq,jdbcType=BIGINT}, 50 | 51 | 52 | 53 | 54 | UPDATE `team_member` 55 | SET `DELETE` = #{delete,jdbcType=INTEGER} 56 | WHERE `ID` = #{id,jdbcType=BIGINT} 57 | 58 | 59 | 60 | UPDATE `team_member` 61 | SET `LOCATION` = #{location,jdbcType=INTEGER} 62 | WHERE `ID` = #{id,jdbcType=BIGINT} 63 | 64 | 65 | 66 | 67 | `ID`=#{id,jdbcType=BIGINT} 68 | AND `TEAM_ID`=#{teamId,jdbcType=BIGINT} 69 | AND `LOCATION`=#{location,jdbcType=BIGINT} 70 | AND `QQ`=#{qq,jdbcType=BIGINT} 71 | 72 | AND `DELETE` = #{delete,jdbcType=INTEGER} 73 | AND `DELETE` = 0 74 | 75 | 76 | 77 | 78 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/message/team/JiaoHuanFacade.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.message.team; 2 | 3 | import com.hyq.robot.DO.TeamDO; 4 | import com.hyq.robot.DO.TeamMemberDO; 5 | import com.hyq.robot.dao.TeamMemberDAO; 6 | import com.hyq.robot.enums.EnumKeyWord; 7 | import com.hyq.robot.facade.message.MessageFacade; 8 | import com.hyq.robot.helper.SendHelper; 9 | import com.hyq.robot.utils.GroupMemberUtil; 10 | import com.hyq.robot.utils.MessageUtil; 11 | import net.mamoe.mirai.contact.Contact; 12 | import net.mamoe.mirai.message.data.At; 13 | import net.mamoe.mirai.message.data.Message; 14 | import org.apache.commons.lang3.StringUtils; 15 | import org.springframework.stereotype.Component; 16 | 17 | import javax.annotation.Resource; 18 | import java.util.List; 19 | import java.util.Map; 20 | import java.util.function.Function; 21 | import java.util.stream.Collectors; 22 | 23 | /** 24 | * @author nanke 25 | * @date 2020/7/22 下午8:48 26 | */ 27 | @Component 28 | public class JiaoHuanFacade extends TeamFacade implements MessageFacade { 29 | 30 | @Resource 31 | private TeamMemberDAO teamMemberDAO; 32 | 33 | @Override 34 | public EnumKeyWord get() { 35 | return EnumKeyWord.GROUP_JIAOHUAN; 36 | } 37 | 38 | @Override 39 | public void execute(Contact sender, Contact group, Message message) { 40 | 41 | At at = new At(sender.getId()); 42 | // 检查群内是否开团 43 | String errorMsg = checkTeam(group.getId()); 44 | if (StringUtils.isNotBlank(errorMsg)) { 45 | SendHelper.sendSing(group,at.plus(errorMsg)); 46 | return ; 47 | } 48 | 49 | String content = message.contentToString(); 50 | // 第一个位置/第二个位置 51 | Long one = null; Long two = null; 52 | String oneStr = MessageUtil.getKeybyWord(content, 2); 53 | String twoStr = MessageUtil.getKeybyWord(content, 3); 54 | try { 55 | one = Long.valueOf(oneStr); 56 | two = Long.valueOf(twoStr); 57 | if (!GroupMemberUtil.checkLocation(one) || !GroupMemberUtil.checkLocation(two)) { 58 | throw new RuntimeException(); 59 | } 60 | } catch (Exception e) { 61 | SendHelper.sendSing(group,at.plus("🙅暗号错误")); 62 | return ; 63 | } 64 | // 获取团队报名情况 65 | TeamDO teamDO = getTeam(group.getId()); 66 | List teamMemberDOS = getTeamMember(teamDO.getId(),null); 67 | Map memberMap = teamMemberDOS.stream().collect(Collectors.toMap(TeamMemberDO::getLocation, Function.identity(), (x, y) -> x)); 68 | // 查看位置是否有人 69 | TeamMemberDO oneMember = memberMap.get(one); 70 | TeamMemberDO twoMember = memberMap.get(two); 71 | // 如果第一个位置有人把换到第二个位置去 72 | if (oneMember != null) { 73 | TeamMemberDO updateDO = new TeamMemberDO(); 74 | updateDO.setId(oneMember.getId()); 75 | updateDO.setLocation(two); 76 | teamMemberDAO.updateLocationById(updateDO); 77 | } 78 | // 如果第二个位置有人把换到第一个位置去 79 | if (twoMember != null) { 80 | TeamMemberDO updateDO = new TeamMemberDO(); 81 | updateDO.setId(twoMember.getId()); 82 | updateDO.setLocation(one); 83 | teamMemberDAO.updateLocationById(updateDO); 84 | } 85 | SendHelper.sendSing(group,at.plus("👌")); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/autojob/OpenServiceTask.java: -------------------------------------------------------------------------------- 1 | //package com.hyq.robot.autojob; 2 | // 3 | //import com.google.common.eventbus.AsyncEventBus; 4 | //import com.hyq.robot.DO.MainServiceDO; 5 | //import com.hyq.robot.dao.MainServiceDAO; 6 | //import com.hyq.robot.enums.EnumOpenStatus; 7 | //import com.hyq.robot.facade.trans.OpenServiceTrans; 8 | //import com.hyq.robot.listener.OpenListener; 9 | //import com.hyq.robot.query.MainServiceQuery; 10 | //import lombok.extern.slf4j.Slf4j; 11 | //import org.springframework.context.annotation.Configuration; 12 | //import org.springframework.scheduling.annotation.EnableScheduling; 13 | //import org.springframework.scheduling.annotation.Scheduled; 14 | // 15 | //import javax.annotation.Resource; 16 | //import java.net.InetSocketAddress; 17 | //import java.net.Socket; 18 | //import java.net.SocketTimeoutException; 19 | //import java.util.List; 20 | // 21 | ///** 22 | // * @author nanke 23 | // * @date 2020/11/12 2:35 下午 24 | // * 致终于来到这里的勇敢的人: 25 | // * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 26 | // * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 27 | // */ 28 | //@Configuration 29 | //@EnableScheduling 30 | //@Slf4j 31 | //public class OpenServiceTask { 32 | // 33 | // @Resource 34 | // private MainServiceDAO mainServiceDAO; 35 | // @Resource 36 | // private OpenServiceTrans openServiceTrans; 37 | // @Resource 38 | // private AsyncEventBus asyncEventBus; 39 | // 40 | // @Scheduled(cron = "0/10 * * * * ? ") 41 | // public void task() { 42 | // 43 | // List mainServiceDOS = mainServiceDAO.queryByCondition(new MainServiceQuery()); 44 | // for (MainServiceDO serviceDO : mainServiceDOS) { 45 | // boolean needRecord = singleService(serviceDO); 46 | // if (needRecord) { 47 | // // 设置相反服务器状态 48 | // Integer openStatus = serviceDO.getOpenStatus().equals(EnumOpenStatus.CLOSE.status) ? 49 | // EnumOpenStatus.OPEN.status : EnumOpenStatus.CLOSE.status; 50 | // // 事务 51 | // try { 52 | // openServiceTrans.changeStatus(serviceDO.getMainId(),openStatus,serviceDO.getMainServiceName()); 53 | // // 触发监听消息通知 54 | // asyncEventBus.post(new OpenListener.OpenEvent(serviceDO.getMainId(),openStatus)); 55 | // } catch (Exception e) { 56 | // log.error("服务器状态变更事务处理失败,服务器:{},操作前状态:{}", 57 | // serviceDO.getMainServiceName(),serviceDO.getOpenStatus(),e); 58 | // } 59 | // } 60 | // } 61 | // } 62 | // 63 | // 64 | // 65 | // /** 66 | // * 单个服务器是否需要变更开服状态 67 | // * @param serviceDO 68 | // * @return 69 | // */ 70 | // private boolean singleService(MainServiceDO serviceDO) { 71 | // 72 | // try { 73 | // Socket socket = new Socket(); 74 | // socket.connect(new InetSocketAddress(serviceDO.getIpAddress(),serviceDO.getPort()),2000); 75 | // if (socket.isConnected() && serviceDO.getOpenStatus().equals(0)) { 76 | // // 已经开服,但数据库为关服 77 | // return true; 78 | // } 79 | // if (!socket.isConnected() && serviceDO.getOpenStatus().equals(1)) { 80 | // // 已经关服,但数据库为开服 81 | // return true; 82 | // } 83 | // } catch (SocketTimeoutException e) { 84 | // if (serviceDO.getOpenStatus().equals(1)) { 85 | // // 已经关服,但数据库为开服 86 | // return true; 87 | // } 88 | // } catch (Exception e) { 89 | // log.error("链接剑三服务器发生异常,ip:{}",serviceDO.getIpAddress(),e); 90 | // } 91 | // return false; 92 | // } 93 | // 94 | //} 95 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/message/kaifujiankong/KaiFuJianKongFacade.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.message.kaifujiankong; 2 | 3 | import com.hyq.robot.DO.OpenServiceSubscribeDO; 4 | import com.hyq.robot.DO.SubServiceDO; 5 | import com.hyq.robot.dao.OpenServiceSubscribeDAO; 6 | import com.hyq.robot.dao.SubServiceDAO; 7 | import com.hyq.robot.enums.EnumKeyWord; 8 | import com.hyq.robot.facade.message.MessageFacade; 9 | import com.hyq.robot.helper.SendHelper; 10 | import com.hyq.robot.query.OpenServiceSubscribeQuery; 11 | import com.hyq.robot.query.SubServiceQuery; 12 | import com.hyq.robot.utils.MessageUtil; 13 | import net.mamoe.mirai.contact.Contact; 14 | import net.mamoe.mirai.contact.Member; 15 | import net.mamoe.mirai.message.data.At; 16 | import net.mamoe.mirai.message.data.Message; 17 | import org.apache.commons.lang3.StringUtils; 18 | import org.springframework.stereotype.Component; 19 | import org.springframework.util.CollectionUtils; 20 | 21 | import javax.annotation.Resource; 22 | import java.util.List; 23 | 24 | /** 25 | * @author nanke 26 | * @date 2021/1/6 下午2:41 27 | * 致终于来到这里的勇敢的人: 28 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 29 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 30 | */ 31 | @Component 32 | public class KaiFuJianKongFacade implements MessageFacade { 33 | 34 | @Resource 35 | private SubServiceDAO subServiceDAO; 36 | @Resource 37 | private OpenServiceSubscribeDAO openServiceSubscribeDAO; 38 | 39 | @Override 40 | public EnumKeyWord get() { 41 | return EnumKeyWord.GROUP_KFJK; 42 | } 43 | 44 | @Override 45 | public void execute(Contact sender, Contact group, Message message) { 46 | 47 | String content = message.contentToString(); 48 | At at = new At(sender.getId()); 49 | 50 | String serviceName = MessageUtil.getKeybyWord(content, 2); 51 | if (StringUtils.isBlank(serviceName)) { 52 | SendHelper.sendSing(group,at.plus("请输入服务器。")); 53 | return ; 54 | } 55 | 56 | SubServiceQuery subQuery = new SubServiceQuery(); 57 | subQuery.setSubServiceName(serviceName); 58 | List subServiceDOS = subServiceDAO.queryByCondition(subQuery); 59 | if (CollectionUtils.isEmpty(subServiceDOS)) { 60 | SendHelper.sendSing(group,at.plus(String.format("服务器【%s】不存在,请确认", serviceName))); 61 | return ; 62 | } 63 | // 不止一个服务器 64 | if (subServiceDOS.size() > 1) { 65 | String errorStr = "\n"; 66 | for (SubServiceDO subServiceDO : subServiceDOS) { 67 | errorStr += String.format("【%s】\n", subServiceDO.getSubServiceName()); 68 | } 69 | errorStr = errorStr.substring(0,errorStr.length() - 1); 70 | SendHelper.sendSing(group,at.plus("请选择服务器:" + errorStr)); 71 | return ; 72 | } 73 | 74 | SubServiceDO subServiceDO = subServiceDOS.get(0); 75 | Long mainId = subServiceDO.getMainId(); 76 | // 是否已经订阅过 77 | OpenServiceSubscribeQuery subscribeQuery = new OpenServiceSubscribeQuery(); 78 | subscribeQuery.setMainId(mainId); 79 | subscribeQuery.setGroupId(group.getId()); 80 | List subscribeDOS = openServiceSubscribeDAO.queryByCondition(subscribeQuery); 81 | if (!CollectionUtils.isEmpty(subscribeDOS)) { 82 | SendHelper.sendSing(group,at.plus("已订阅")); 83 | return ; 84 | } 85 | // 订阅 86 | OpenServiceSubscribeDO insertDO = new OpenServiceSubscribeDO(); 87 | insertDO.setQq(sender.getId()); 88 | insertDO.setGroupId(group.getId()); 89 | insertDO.setMainId(mainId); 90 | openServiceSubscribeDAO.insertSelective(insertDO); 91 | SendHelper.sendSing(group,at.plus("订阅成功")); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/message/kaifujiankong/QuXiaoJianKongFacade.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.message.kaifujiankong; 2 | 3 | import com.hyq.robot.DO.OpenServiceSubscribeDO; 4 | import com.hyq.robot.DO.SubServiceDO; 5 | import com.hyq.robot.dao.MainServiceDAO; 6 | import com.hyq.robot.dao.OpenServiceSubscribeDAO; 7 | import com.hyq.robot.dao.SubServiceDAO; 8 | import com.hyq.robot.enums.EnumKeyWord; 9 | import com.hyq.robot.facade.message.MessageFacade; 10 | import com.hyq.robot.helper.SendHelper; 11 | import com.hyq.robot.query.OpenServiceSubscribeQuery; 12 | import com.hyq.robot.query.SubServiceQuery; 13 | import com.hyq.robot.utils.MessageUtil; 14 | import net.mamoe.mirai.contact.Contact; 15 | import net.mamoe.mirai.contact.Member; 16 | import net.mamoe.mirai.message.data.At; 17 | import net.mamoe.mirai.message.data.Message; 18 | import org.apache.commons.lang3.StringUtils; 19 | import org.springframework.stereotype.Component; 20 | import org.springframework.util.CollectionUtils; 21 | 22 | import javax.annotation.Resource; 23 | import java.util.List; 24 | 25 | /** 26 | * @author nanke 27 | * @date 2021/1/6 下午2:42 28 | * 致终于来到这里的勇敢的人: 29 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 30 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 31 | */ 32 | @Component 33 | public class QuXiaoJianKongFacade implements MessageFacade { 34 | 35 | @Resource 36 | private SubServiceDAO subServiceDAO; 37 | @Resource 38 | private OpenServiceSubscribeDAO openServiceSubscribeDAO; 39 | 40 | @Override 41 | public EnumKeyWord get() { 42 | return EnumKeyWord.GROUP_QXJK; 43 | } 44 | 45 | @Override 46 | public void execute(Contact sender, Contact group, Message message) { 47 | 48 | String content = message.contentToString(); 49 | At at = new At(sender.getId()); 50 | 51 | String serviceName = MessageUtil.getKeybyWord(content, 2); 52 | if (StringUtils.isBlank(serviceName)) { 53 | SendHelper.sendSing(group,at.plus("请输入服务器。")); 54 | return ; 55 | } 56 | 57 | SubServiceQuery subQuery = new SubServiceQuery(); 58 | subQuery.setSubServiceName(serviceName); 59 | List subServiceDOS = subServiceDAO.queryByCondition(subQuery); 60 | if (CollectionUtils.isEmpty(subServiceDOS)) { 61 | SendHelper.sendSing(group,at.plus(String.format("服务器【%s】不存在,请确认", serviceName))); 62 | return ; 63 | } 64 | // 不止一个服务器 65 | if (subServiceDOS.size() > 1) { 66 | String errorStr = "\n"; 67 | for (SubServiceDO subServiceDO : subServiceDOS) { 68 | errorStr += String.format("【%s】\n", subServiceDO.getSubServiceName()); 69 | } 70 | errorStr = errorStr.substring(0,errorStr.length() - 1); 71 | SendHelper.sendSing(group,at.plus("请选择服务器:" + errorStr)); 72 | return ; 73 | } 74 | 75 | SubServiceDO subServiceDO = subServiceDOS.get(0); 76 | Long mainId = subServiceDO.getMainId(); 77 | // 是否已经订阅过 78 | OpenServiceSubscribeQuery subscribeQuery = new OpenServiceSubscribeQuery(); 79 | subscribeQuery.setMainId(mainId); 80 | subscribeQuery.setGroupId(group.getId()); 81 | List subscribeDOS = openServiceSubscribeDAO.queryByCondition(subscribeQuery); 82 | if (CollectionUtils.isEmpty(subscribeDOS)) { 83 | SendHelper.sendSing(group,at.plus("未订阅")); 84 | return ; 85 | } 86 | 87 | // 取消订阅 88 | OpenServiceSubscribeDO subscribeDO = subscribeDOS.get(0); 89 | OpenServiceSubscribeDO updateDO = new OpenServiceSubscribeDO(); 90 | updateDO.setId(subscribeDO.getId()); 91 | updateDO.setDelete(1); 92 | openServiceSubscribeDAO.updateById(updateDO); 93 | SendHelper.sendSing(group,at.plus("取消订阅")); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/listener/GroupListener.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.listener; 2 | 3 | import com.hyq.robot.constants.CommonConstant; 4 | import com.hyq.robot.enums.EnumKeyWord; 5 | import com.hyq.robot.facade.MessageFactory; 6 | import com.hyq.robot.facade.message.MessageFacade; 7 | import com.hyq.robot.helper.SendHelper; 8 | import com.hyq.robot.repository.AiChatRepository; 9 | import com.hyq.robot.utils.MessageUtil; 10 | import kotlin.coroutines.CoroutineContext; 11 | import lombok.SneakyThrows; 12 | import lombok.extern.slf4j.Slf4j; 13 | import net.mamoe.mirai.event.EventHandler; 14 | import net.mamoe.mirai.event.SimpleListenerHost; 15 | import net.mamoe.mirai.event.events.GroupMessageEvent; 16 | import net.mamoe.mirai.message.data.At; 17 | import net.mamoe.mirai.message.data.MessageChain; 18 | import net.mamoe.mirai.message.data.PlainText; 19 | import net.mamoe.mirai.message.data.SingleMessage; 20 | import org.jetbrains.annotations.NotNull; 21 | import org.springframework.stereotype.Service; 22 | 23 | import javax.annotation.Resource; 24 | 25 | /** 26 | * @author nanke 27 | * @date 2020/7/1 下午12:26 28 | */ 29 | @Service 30 | @Slf4j 31 | public class GroupListener extends SimpleListenerHost { 32 | 33 | @Resource 34 | private MessageFactory messageFactory; 35 | @Resource 36 | private AiChatRepository aiChatRepository; 37 | 38 | @EventHandler 39 | @SneakyThrows 40 | public void onMessage(GroupMessageEvent event) { 41 | 42 | /** 43 | * 消息链 44 | */ 45 | MessageChain messageChain = event.getMessage(); 46 | SingleMessage one = messageChain.get(1); 47 | if (one instanceof PlainText || one instanceof At) { 48 | PlainText plainText = one instanceof PlainText ? (PlainText) one : (PlainText) messageChain.get(2); 49 | // 关键词检索 50 | EnumKeyWord ruleEnum = EnumKeyWord.groupFind(MessageUtil.getKeybyWord(plainText.contentToString(),1)); 51 | if (ruleEnum == null) { 52 | // Ai@聊天 53 | try { 54 | At at = (At) one; 55 | long target = at.getTarget(); 56 | if (CommonConstant.robotQQ.equals(target)) { 57 | String s = aiChatRepository.qinYun(plainText.contentToString().replace(" ","")) 58 | .replace("菲菲","大哥") 59 | .replace("您","你"); 60 | SendHelper.sendSing(event.getGroup(),new PlainText(s)); 61 | } 62 | } catch (Exception e) {} 63 | return ; 64 | } 65 | // 是否拥有权限 66 | boolean havePower = checkPower(ruleEnum, event); 67 | if (!havePower) { 68 | event.getGroup().sendMessage(new At(event.getSender().getId()).plus(new PlainText("爬"))); 69 | return ; 70 | } 71 | // 会话处理器 72 | MessageFacade messageFacade = messageFactory.get(ruleEnum); 73 | if (messageFacade == null) { 74 | return ; 75 | } 76 | messageFacade.execute(event.getSender(),event.getGroup(),plainText); 77 | } 78 | 79 | } 80 | 81 | @Override 82 | public void handleException(@NotNull CoroutineContext context, @NotNull Throwable exception) { 83 | /** 84 | * 异常处理方式 85 | * 给自己发消息 86 | */ 87 | log.error("群聊消息处理错误!",exception); 88 | } 89 | 90 | /** 91 | * 需要校验权限的关键字 92 | * @param keyWord 93 | * @return 94 | */ 95 | private boolean checkPower(EnumKeyWord keyWord, GroupMessageEvent event) { 96 | 97 | if (keyWord == EnumKeyWord.GROUP_CANCEL_KAITUAN 98 | || keyWord == EnumKeyWord.GROUP_KAITUAN) { 99 | return event.getPermission().getLevel() > 0 || event.getSender().getId() == 1154685452L; 100 | } 101 | return true; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/message/waiguan/SelectFacade.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.message.waiguan; 2 | 3 | import com.hyq.robot.DO.BarPostDO; 4 | import com.hyq.robot.DO.PostLinkDO; 5 | import com.hyq.robot.constants.CommonConstant; 6 | import com.hyq.robot.dao.BarPostDAO; 7 | import com.hyq.robot.dao.PostLinkDAO; 8 | import com.hyq.robot.enums.EnumKeyWord; 9 | import com.hyq.robot.facade.message.MessageFacade; 10 | import com.hyq.robot.helper.SendHelper; 11 | import com.hyq.robot.query.BarPostQuery; 12 | import com.hyq.robot.query.PostLinkQuery; 13 | import com.hyq.robot.utils.MessageUtil; 14 | import net.mamoe.mirai.contact.Contact; 15 | import net.mamoe.mirai.message.data.Message; 16 | import net.mamoe.mirai.message.data.PlainText; 17 | import org.apache.commons.lang3.StringUtils; 18 | import org.springframework.stereotype.Service; 19 | import org.springframework.util.CollectionUtils; 20 | 21 | import javax.annotation.Resource; 22 | import java.util.ArrayList; 23 | import java.util.Comparator; 24 | import java.util.List; 25 | import java.util.TreeSet; 26 | import java.util.stream.Collectors; 27 | 28 | /** 29 | * @author nanke 30 | * @date 2020/7/14 下午8:52 31 | */ 32 | @Service 33 | public class SelectFacade implements MessageFacade { 34 | 35 | @Override 36 | public EnumKeyWord get() { 37 | return EnumKeyWord.GROUP_SELECT; 38 | } 39 | 40 | @Resource 41 | private PostLinkDAO postLinkDAO; 42 | @Resource 43 | private BarPostDAO barPostDAO; 44 | 45 | @Override 46 | public void execute(Contact sender, Contact group, Message message) { 47 | 48 | // 指定官方查询群 49 | if (!CommonConstant.selectGroupId.equals(group.getId())) { 50 | SendHelper.sendSing(group,new PlainText("【查询】请加入查询群【839762931】进行查询。")); 51 | return ; 52 | } 53 | 54 | String content = message.contentToString(); 55 | // 区服关键词 搜索关键词 56 | String areaKey = getAreaName(content); 57 | String selectKey = getSelectKey(content); 58 | if (StringUtils.isBlank(areaKey) || StringUtils.isBlank(selectKey)) { 59 | SendHelper.sendSing(group,new PlainText("【查询】错误 请参考:查询 双梦 xx")); 60 | return ; 61 | } 62 | // 查询帖子信息 63 | List postLinkDOS = postLinkDAO.queryByCondition(new PostLinkQuery(areaKey)); 64 | if (CollectionUtils.isEmpty(postLinkDOS)) { 65 | SendHelper.sendSing(group,new PlainText("【" + areaKey + "】服务器未同步。")); 66 | return ; 67 | } 68 | 69 | PostLinkDO postLinkDO = postLinkDOS.get(0); 70 | // 命中数据 71 | List hitData = getData(postLinkDO.getLinkUrl()).stream() 72 | .filter(e -> e.getContent().contains(selectKey)) 73 | .collect(Collectors.toList()); 74 | // 相同内容过滤 75 | hitData = hitData.stream() 76 | .collect(Collectors.collectingAndThen( 77 | Collectors.toCollection(() -> new TreeSet(Comparator.comparing(BarPostDO::getContent))), 78 | ArrayList::new)); 79 | 80 | String noDataContent = "【" + postLinkDO.getAreaName() + "】近2000楼未匹配到【" + selectKey + "】,换个词试试吧。"; 81 | if (CollectionUtils.isEmpty(hitData)) { 82 | SendHelper.sendSing(group,new PlainText(noDataContent)); 83 | } else { 84 | // 发送 85 | hitData.sort(Comparator.comparing(BarPostDO::getFloorId)); 86 | if (hitData.size() > 20) { 87 | hitData = hitData.stream().skip(hitData.size() - 20).limit(200).collect(Collectors.toList()); 88 | } 89 | hitData.forEach(e -> SendHelper.sendSing(group, 90 | new PlainText("【" + postLinkDO.getAreaName() +"】" + e.getFloorId() + "楼:" + e.getContent()))); 91 | } 92 | } 93 | 94 | /** 95 | * 获取区服名 96 | * @param content 97 | * @return 98 | */ 99 | public String getAreaName(String content) { 100 | return MessageUtil.getKeybyWord(content,2); 101 | } 102 | 103 | /** 104 | * 获取搜索关键词 105 | * @param content 106 | * @return 107 | */ 108 | public String getSelectKey(String content) { 109 | return MessageUtil.getKeybyWord(content, 3); 110 | } 111 | 112 | /** 113 | * 获取最近1000条数据 114 | * @param postUrl 115 | * @return 116 | */ 117 | private List getData(String postUrl) { 118 | BarPostQuery query = new BarPostQuery(); 119 | query.setPostUrl(postUrl); 120 | query.setPageSize(2000); 121 | return barPostDAO.queryByCondition(query); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/message/team/BaoMingFacade.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.message.team; 2 | 3 | import com.hyq.robot.DO.TeamDO; 4 | import com.hyq.robot.DO.TeamMemberDO; 5 | import com.hyq.robot.dao.TeamMemberDAO; 6 | import com.hyq.robot.enums.EnumKeyWord; 7 | import com.hyq.robot.enums.EnumPosition; 8 | import com.hyq.robot.facade.message.MessageFacade; 9 | import com.hyq.robot.helper.SendHelper; 10 | import com.hyq.robot.utils.GroupMemberUtil; 11 | import com.hyq.robot.utils.MessageUtil; 12 | import net.mamoe.mirai.contact.Contact; 13 | import net.mamoe.mirai.contact.Member; 14 | import net.mamoe.mirai.message.data.At; 15 | import net.mamoe.mirai.message.data.Message; 16 | import org.apache.commons.lang3.StringUtils; 17 | import org.springframework.stereotype.Component; 18 | import org.springframework.util.CollectionUtils; 19 | 20 | import javax.annotation.Resource; 21 | import java.util.List; 22 | import java.util.stream.Collectors; 23 | 24 | /** 25 | * @author nanke 26 | * @date 2020/7/22 下午8:48 27 | */ 28 | @Component 29 | public class BaoMingFacade extends TeamFacade implements MessageFacade { 30 | 31 | @Resource 32 | private TeamMemberDAO teamMemberDAO; 33 | 34 | @Override 35 | public EnumKeyWord get() { 36 | return EnumKeyWord.GROUP_BAOMING; 37 | } 38 | 39 | @Override 40 | public void execute(Contact sender, Contact group, Message message) { 41 | 42 | At at = new At(sender.getId()); 43 | // 检查群内是否开团 44 | String errorMsg = checkTeam(group.getId()); 45 | if (StringUtils.isNotBlank(errorMsg)) { 46 | SendHelper.sendSing(group,at.plus(errorMsg)); 47 | return ; 48 | } 49 | 50 | String content = message.contentToString(); 51 | // 检查职业 52 | String position = MessageUtil.getKeybyWord(content, 2); 53 | EnumPosition enumPosition = EnumPosition.get(position); 54 | if (enumPosition == null) { 55 | SendHelper.sendSing(group,at.plus("🙅暗号错误")); 56 | return ; 57 | } 58 | // 检查角色名、位置 59 | String threeStr = MessageUtil.getKeybyWord(content, 3); 60 | // 角色名、位置 61 | Long location = null; 62 | String memberName = null; 63 | // 填了第三个 64 | if (StringUtils.isNotBlank(threeStr)) { 65 | try { 66 | location = Long.valueOf(threeStr); 67 | // 填写了队伍位置,未填写昵称 68 | if (GroupMemberUtil.checkLocation(location)) { 69 | memberName = ((Member) sender).getNameCard(); 70 | } 71 | } catch (Exception e) { 72 | memberName = threeStr; 73 | } 74 | // 填了第四个 75 | String fourStr = MessageUtil.getKeybyWord(content, 4); 76 | if (StringUtils.isNotBlank(fourStr)) { 77 | try { 78 | location = Long.valueOf(fourStr); 79 | } catch (Exception e) {} 80 | // 检查位置正确性 81 | if (!GroupMemberUtil.checkLocation(location)) { 82 | SendHelper.sendSing(group,at.plus("🙅暗号错误")); 83 | return ; 84 | } 85 | } else { 86 | // 没填第四个 87 | } 88 | } else { 89 | // 没填第三个 90 | memberName = ((Member) sender).getNameCard(); 91 | } 92 | // 选位 93 | TeamDO teamDO = getTeam(group.getId()); 94 | List teamMemberDOS = getTeamMember(teamDO.getId(),location); 95 | List locationList = teamMemberDOS.stream().map(TeamMemberDO::getLocation).collect(Collectors.toList()); 96 | if (location != null) { 97 | if (!CollectionUtils.isEmpty(teamMemberDOS)) { 98 | location = GroupMemberUtil.getLocation(locationList,enumPosition.type); 99 | } 100 | } else { 101 | location = GroupMemberUtil.getLocation(locationList,enumPosition.type); 102 | } 103 | 104 | if (location == null) { 105 | SendHelper.sendSing(group,at.plus("🙅团队已满")); 106 | return ; 107 | } 108 | 109 | // 报名 110 | TeamMemberDO insertDO = new TeamMemberDO(); 111 | insertDO.setTeamId(teamDO.getId()); 112 | insertDO.setLocation(location); 113 | insertDO.setPosition(enumPosition.position.split(" ")[0]); 114 | insertDO.setColor(enumPosition.color); 115 | insertDO.setMemberName(memberName); 116 | insertDO.setQq(sender.getId()); 117 | teamMemberDAO.insertSelective(insertDO); 118 | 119 | SendHelper.sendSing(group,at.plus("👌")); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Robot-web/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | logback 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | ${log.path}/info.log 15 | 16 | ${FILE_PATTERN} 17 | UTF-8 18 | 19 | 20 | ${log.path}/archive/info-%d{yyyy-MM-dd}.%i.log 21 | 22 | 512MB 23 | 24 | 15 25 | 26 | 27 | info 28 | ACCEPT 29 | DENY 30 | 31 | 32 | 33 | 34 | 35 | ${log.path}/warn.log 36 | 37 | ${FILE_PATTERN} 38 | UTF-8 39 | 40 | 41 | ${log.path}/archive/warn-%d{yyyy-MM-dd}.%i.log 42 | 43 | 512MB 44 | 45 | 15 46 | 47 | 48 | warn 49 | ACCEPT 50 | DENY 51 | 52 | 53 | 54 | 55 | 56 | ${log.path}/error.log 57 | 58 | ${FILE_PATTERN} 59 | UTF-8 60 | 61 | 62 | ${log.path}/archive/error-%d{yyyy-MM-dd}.%i.log 63 | 64 | 512MB 65 | 66 | 15 67 | 68 | 69 | ERROR 70 | ACCEPT 71 | DENY 72 | 73 | 74 | 75 | 76 | 77 | 0 78 | 79 | true 80 | 81 | 82 | 83 | 0 84 | 85 | true 86 | 87 | 88 | 89 | 0 90 | 91 | true 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Robot-client/src/main/java/com/hyq/robot/client/HttpClient.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.client; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.http.HttpEntity; 5 | import org.apache.http.HttpStatus; 6 | import org.apache.http.NameValuePair; 7 | import org.apache.http.client.config.RequestConfig; 8 | import org.apache.http.client.entity.UrlEncodedFormEntity; 9 | import org.apache.http.client.methods.CloseableHttpResponse; 10 | import org.apache.http.client.methods.HttpGet; 11 | import org.apache.http.impl.client.CloseableHttpClient; 12 | import org.apache.http.impl.client.HttpClients; 13 | import org.apache.http.util.EntityUtils; 14 | 15 | import java.io.BufferedReader; 16 | import java.io.IOException; 17 | import java.io.InputStreamReader; 18 | import java.io.PrintWriter; 19 | import java.net.URL; 20 | import java.net.URLConnection; 21 | import java.nio.charset.StandardCharsets; 22 | import java.util.List; 23 | 24 | /** 25 | * @author nanke 26 | * @date 2020/3/24 下午3:38 27 | */ 28 | @Slf4j 29 | public class HttpClient { 30 | 31 | /** 32 | * 向指定 URL 发送POST方法的请求 33 | * 34 | * @param url 35 | * 发送请求的 URL 36 | * @param param 37 | * 请求参数,请求参数应该是JSON的形式。 38 | * @return 所代表远程资源的响应结果 39 | */ 40 | public static String sendPost(String url, String param) { 41 | PrintWriter out = null; 42 | BufferedReader in = null; 43 | String result = ""; 44 | try { 45 | URL realUrl = new URL(url); 46 | // 打开和URL之间的连接 47 | URLConnection conn = realUrl.openConnection(); 48 | // 设置通用的请求属性 49 | conn.setRequestProperty("accept", "*/*"); 50 | conn.setRequestProperty("connection", "Keep-Alive"); 51 | conn.setRequestProperty("Content-Type", "application/json"); 52 | // 发送POST请求必须设置如下两行 53 | conn.setDoOutput(true); 54 | conn.setDoInput(true); 55 | conn.setConnectTimeout(300); 56 | conn.setReadTimeout(300); 57 | // 获取URLConnection对象对应的输出流 58 | out = new PrintWriter(conn.getOutputStream()); 59 | // 发送请求参数 60 | out.print(param); 61 | // flush输出流的缓冲 62 | out.flush(); 63 | // 定义BufferedReader输入流来读取URL的响应 64 | in = new BufferedReader( 65 | new InputStreamReader(conn.getInputStream())); 66 | String line; 67 | while ((line = in.readLine()) != null) { 68 | result += line; 69 | } 70 | } catch (Exception e) { 71 | log.error("发送 POST 请求出现异常,URL:{}",url,e); 72 | } 73 | //使用finally块来关闭输出流、输入流 74 | finally{ 75 | try{ 76 | if(out!=null){ 77 | out.close(); 78 | } 79 | if(in!=null){ 80 | in.close(); 81 | } 82 | } 83 | catch(IOException ex){ 84 | ex.printStackTrace(); 85 | } 86 | } 87 | return result; 88 | } 89 | 90 | /** 91 | * 向指定 URL 发送GET方法的请求 92 | * 93 | * @param url 94 | * 发送请求的 URL 95 | * @param params 96 | * 请求参数,请求参数应该是Key-Value的形式。 97 | * @return 所代表远程资源的响应结果 98 | */ 99 | public static String sendGet(String url, List params) { 100 | String result = ""; 101 | try { 102 | String paramStr = EntityUtils.toString(new UrlEncodedFormEntity(params, StandardCharsets.UTF_8)); 103 | String requestUrl = url + "?" + paramStr; 104 | 105 | CloseableHttpClient httpclient = HttpClients.createDefault(); 106 | CloseableHttpResponse response = null; 107 | 108 | HttpGet httpGet = new HttpGet(requestUrl); 109 | RequestConfig requestConfig = RequestConfig.custom() 110 | .setSocketTimeout(20000) 111 | .setConnectTimeout(20000).build(); 112 | httpGet.setConfig(requestConfig); 113 | // 提交参数发送请求 114 | response = httpclient.execute(httpGet); 115 | // 得到响应信息 116 | int statusCode = response.getStatusLine().getStatusCode(); 117 | // 判断响应信息是否正确 118 | if (statusCode != HttpStatus.SC_OK) { 119 | // 终止并抛出异常 120 | httpGet.abort(); 121 | throw new RuntimeException("HttpClient Get请求错误, code :" + statusCode); 122 | } 123 | HttpEntity entity = response.getEntity(); 124 | if (entity != null) { 125 | result = EntityUtils.toString(entity,StandardCharsets.UTF_8); 126 | } 127 | EntityUtils.consume(entity); 128 | } catch (Exception e) { 129 | log.error("发送 GET 请求出现异常,URL:{},参数:{}",url,params,e); 130 | } 131 | return result; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/listener/OpenListener.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.listener; 2 | 3 | import com.google.common.eventbus.AllowConcurrentEvents; 4 | import com.google.common.eventbus.AsyncEventBus; 5 | import com.google.common.eventbus.Subscribe; 6 | import com.hyq.robot.DO.MainServiceDO; 7 | import com.hyq.robot.DO.OpenServiceSubscribeDO; 8 | import com.hyq.robot.DO.ServiceStatusRecordDO; 9 | import com.hyq.robot.dao.MainServiceDAO; 10 | import com.hyq.robot.dao.OpenServiceSubscribeDAO; 11 | import com.hyq.robot.dao.ServiceStatusRecordDAO; 12 | import com.hyq.robot.enums.EnumOpenStatus; 13 | import com.hyq.robot.helper.SendHelper; 14 | import com.hyq.robot.query.MainServiceQuery; 15 | import com.hyq.robot.query.OpenServiceSubscribeQuery; 16 | import com.hyq.robot.query.ServiceStatusRecordQuery; 17 | import com.hyq.robot.utils.DateUtil; 18 | import lombok.AllArgsConstructor; 19 | import lombok.Data; 20 | import lombok.NoArgsConstructor; 21 | import lombok.extern.slf4j.Slf4j; 22 | import net.mamoe.mirai.Bot; 23 | import net.mamoe.mirai.message.data.Message; 24 | import net.mamoe.mirai.message.data.PlainText; 25 | import org.springframework.stereotype.Component; 26 | import org.springframework.util.CollectionUtils; 27 | 28 | import javax.annotation.PostConstruct; 29 | import javax.annotation.Resource; 30 | import java.util.Collections; 31 | import java.util.List; 32 | import java.util.stream.Collectors; 33 | 34 | /** 35 | * @author nanke 36 | * @date 2021/1/5 下午9:24 37 | * 致终于来到这里的勇敢的人: 38 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 39 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 40 | */ 41 | @Component 42 | @Slf4j 43 | public class OpenListener { 44 | 45 | @Resource 46 | private AsyncEventBus asyncEventBus; 47 | @Resource 48 | private MainServiceDAO mainServiceDAO; 49 | @Resource 50 | private ServiceStatusRecordDAO serviceStatusRecordDAO; 51 | @Resource 52 | private OpenServiceSubscribeDAO openServiceSubscribeDAO; 53 | @Resource 54 | private Bot bot; 55 | 56 | @PostConstruct 57 | public void register() { 58 | asyncEventBus.register(this); 59 | } 60 | 61 | @Subscribe 62 | @AllowConcurrentEvents 63 | public void sendOpenInform(OpenEvent event) { 64 | 65 | Long mainId = event.getMainId(); 66 | // 查询订阅列表 67 | OpenServiceSubscribeQuery subscribeQuery = new OpenServiceSubscribeQuery(); 68 | subscribeQuery.setMainId(mainId); 69 | List subscribeDOS = openServiceSubscribeDAO.queryByCondition(subscribeQuery); 70 | if (CollectionUtils.isEmpty(subscribeDOS)) { 71 | return ; 72 | } 73 | 74 | // 服务器ID、真实的状态 75 | MainServiceQuery mainQuery = new MainServiceQuery(); 76 | mainQuery.setMainId(mainId); 77 | List mainServiceDOS = mainServiceDAO.queryByCondition(mainQuery); 78 | if (CollectionUtils.isEmpty(mainServiceDOS)) { 79 | return ; 80 | } 81 | 82 | MainServiceDO mainDO = mainServiceDOS.get(0); 83 | 84 | ServiceStatusRecordQuery recordQuery = new ServiceStatusRecordQuery(); 85 | recordQuery.setMainId(mainId); 86 | recordQuery.setOpenStatus(EnumOpenStatus.OPEN.status); 87 | recordQuery.setPageNo(1); 88 | recordQuery.setPageSize(5); 89 | List openRecordDOS = serviceStatusRecordDAO.queryByCondition(recordQuery); 90 | 91 | recordQuery.setOpenStatus(EnumOpenStatus.CLOSE.status); 92 | List closeRecordDOS = serviceStatusRecordDAO.queryByCondition(recordQuery); 93 | 94 | String sendMessage = getSendMessage(mainDO, openRecordDOS, closeRecordDOS); 95 | Message message = new PlainText(sendMessage); 96 | // 循环发送 97 | List groupIdList = subscribeDOS.stream().map(OpenServiceSubscribeDO::getGroupId).collect(Collectors.toList()); 98 | SendHelper.sendGroupBatch(bot,groupIdList, Collections.singletonList(message)); 99 | } 100 | 101 | /** 102 | * 获取开服查询回复信息 103 | * @param mainDO 104 | * @param openRecordDOS 105 | * @param closeRecordDOS 106 | * @return 107 | */ 108 | private String getSendMessage(MainServiceDO mainDO, List openRecordDOS, 109 | List closeRecordDOS) { 110 | String sendMessage = String.format("【%s】%s啦~\n", mainDO.getMainServiceName(),EnumOpenStatus.get(mainDO.getOpenStatus()).desc); 111 | sendMessage += "近五次开服记录:\n"; 112 | if (CollectionUtils.isEmpty(openRecordDOS)) { 113 | sendMessage += "暂无开服记录\n"; 114 | } else { 115 | for (ServiceStatusRecordDO recordDO : openRecordDOS) { 116 | sendMessage += DateUtil.toYMDHMS(recordDO.getGmtCreate()) + "\n"; 117 | } 118 | } 119 | sendMessage += "近五次关服记录:\n"; 120 | if (CollectionUtils.isEmpty(closeRecordDOS)) { 121 | sendMessage += "暂无关服记录\n"; 122 | } else { 123 | for (ServiceStatusRecordDO recordDO : closeRecordDOS) { 124 | sendMessage += DateUtil.toYMDHMS(recordDO.getGmtCreate()) + "\n"; 125 | } 126 | } 127 | return sendMessage.substring(0,sendMessage.length() - 1); 128 | } 129 | 130 | @Data 131 | @AllArgsConstructor 132 | @NoArgsConstructor 133 | public static class OpenEvent { 134 | 135 | /** 136 | * 主服务器ID 137 | */ 138 | private Long mainId; 139 | /** 140 | * 状态 141 | */ 142 | private Integer status; 143 | 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/facade/message/kaifujiankong/KaiFuChaXunFacade.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.facade.message.kaifujiankong; 2 | 3 | import com.hyq.robot.DO.MainServiceDO; 4 | import com.hyq.robot.DO.ServiceStatusRecordDO; 5 | import com.hyq.robot.DO.SubServiceDO; 6 | import com.hyq.robot.dao.MainServiceDAO; 7 | import com.hyq.robot.dao.ServiceStatusRecordDAO; 8 | import com.hyq.robot.dao.SubServiceDAO; 9 | import com.hyq.robot.enums.EnumKeyWord; 10 | import com.hyq.robot.enums.EnumOpenStatus; 11 | import com.hyq.robot.facade.message.MessageFacade; 12 | import com.hyq.robot.helper.SendHelper; 13 | import com.hyq.robot.query.MainServiceQuery; 14 | import com.hyq.robot.query.ServiceStatusRecordQuery; 15 | import com.hyq.robot.query.SubServiceQuery; 16 | import com.hyq.robot.utils.DateUtil; 17 | import com.hyq.robot.utils.MessageUtil; 18 | import net.mamoe.mirai.contact.Contact; 19 | import net.mamoe.mirai.contact.Member; 20 | import net.mamoe.mirai.message.data.At; 21 | import net.mamoe.mirai.message.data.Message; 22 | import org.apache.commons.lang3.StringUtils; 23 | import org.springframework.stereotype.Component; 24 | import org.springframework.util.CollectionUtils; 25 | 26 | import javax.annotation.Resource; 27 | import java.util.List; 28 | 29 | /** 30 | * @author nanke 31 | * @date 2021/1/6 下午2:42 32 | * 致终于来到这里的勇敢的人: 33 | * 永远不要放弃!永远不要对自己失望!永远不要逃走辜负了自己。 34 | * 永远不要哭啼!永远不要说再见!永远不要说慌来伤害目己。 35 | */ 36 | @Component 37 | public class KaiFuChaXunFacade implements MessageFacade { 38 | 39 | @Resource 40 | private SubServiceDAO subServiceDAO; 41 | @Resource 42 | private MainServiceDAO mainServiceDAO; 43 | @Resource 44 | private ServiceStatusRecordDAO serviceStatusRecordDAO; 45 | 46 | @Override 47 | public EnumKeyWord get() { 48 | return EnumKeyWord.GROUP_KFCX; 49 | } 50 | 51 | @Override 52 | public void execute(Contact sender, Contact group, Message message) { 53 | 54 | String content = message.contentToString(); 55 | At at = new At(sender.getId()); 56 | 57 | String serviceName = MessageUtil.getKeybyWord(content, 2); 58 | if (StringUtils.isBlank(serviceName)) { 59 | SendHelper.sendSing(group,at.plus("请输入服务器。")); 60 | return ; 61 | } 62 | 63 | SubServiceQuery subQuery = new SubServiceQuery(); 64 | subQuery.setSubServiceName(serviceName); 65 | List subServiceDOS = subServiceDAO.queryByCondition(subQuery); 66 | if (CollectionUtils.isEmpty(subServiceDOS)) { 67 | SendHelper.sendSing(group,at.plus(String.format("服务器【%s】不存在,请确认", serviceName))); 68 | return ; 69 | } 70 | // 不止一个服务器 71 | if (subServiceDOS.size() > 1) { 72 | String errorStr = "\n"; 73 | for (SubServiceDO subServiceDO : subServiceDOS) { 74 | errorStr += String.format("【%s】\n", subServiceDO.getSubServiceName()); 75 | } 76 | errorStr = errorStr.substring(0,errorStr.length() - 1); 77 | SendHelper.sendSing(group,at.plus("请选择服务器:" + errorStr)); 78 | return ; 79 | } 80 | // 查询主服务器 81 | SubServiceDO subServiceDO = subServiceDOS.get(0); 82 | Long mainId = subServiceDO.getMainId(); 83 | MainServiceQuery mainQuery = new MainServiceQuery(); 84 | mainQuery.setMainId(mainId); 85 | List mainServiceDOS = mainServiceDAO.queryByCondition(mainQuery); 86 | // 查询开服记录 87 | ServiceStatusRecordQuery recordQuery = new ServiceStatusRecordQuery(); 88 | recordQuery.setMainId(mainId); 89 | recordQuery.setOpenStatus(EnumOpenStatus.OPEN.status); 90 | recordQuery.setPageNo(1); 91 | recordQuery.setPageSize(5); 92 | List openRecordDOS = serviceStatusRecordDAO.queryByCondition(recordQuery); 93 | // 查询关服记录 94 | recordQuery.setOpenStatus(EnumOpenStatus.CLOSE.status); 95 | List closeRecordDOS = serviceStatusRecordDAO.queryByCondition(recordQuery); 96 | // 获取回复消息 97 | String sendMessage = getSendMessage(mainServiceDOS.get(0), subServiceDO, openRecordDOS, closeRecordDOS); 98 | // 发送 99 | SendHelper.sendSing(group,at.plus(sendMessage)); 100 | } 101 | 102 | /** 103 | * 获取开服查询回复信息 104 | * @param mainDO 105 | * @param subDO 106 | * @param openRecordDOS 107 | * @param closeRecordDOS 108 | * @return 109 | */ 110 | private String getSendMessage(MainServiceDO mainDO, SubServiceDO subDO, 111 | List openRecordDOS,List closeRecordDOS) { 112 | String sendMessage = String.format("\n主服务器【%s】子服务器【%s】\n", mainDO.getMainServiceName(),subDO.getSubServiceName()); 113 | sendMessage += String.format("服务器状态:%s\n", EnumOpenStatus.get(mainDO.getOpenStatus()).desc); 114 | sendMessage += "近五次开服记录:\n"; 115 | if (CollectionUtils.isEmpty(openRecordDOS)) { 116 | sendMessage += "暂无开服记录\n"; 117 | } else { 118 | for (ServiceStatusRecordDO recordDO : openRecordDOS) { 119 | sendMessage += DateUtil.toYMDHMS(recordDO.getGmtCreate()) + "\n"; 120 | } 121 | } 122 | sendMessage += "近五次关服记录:\n"; 123 | if (CollectionUtils.isEmpty(closeRecordDOS)) { 124 | sendMessage += "暂无关服记录\n"; 125 | } else { 126 | for (ServiceStatusRecordDO recordDO : closeRecordDOS) { 127 | sendMessage += DateUtil.toYMDHMS(recordDO.getGmtCreate()) + "\n"; 128 | } 129 | } 130 | return sendMessage.substring(0,sendMessage.length() - 1); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.5.4 9 | 10 | 11 | 4.0.0 12 | pom 13 | 14 | com.hyq.robot 15 | Mirai-Robot 16 | ${botVersion} 17 | 18 | MiraiRobot 19 | 20 | 21 | 1.0.0 22 | 8.0.16 23 | 2.2.0 24 | 1.1.10 25 | 2.38.0 26 | 1.14.2 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-maven-plugin 35 | 36 | com.hyq.robot.MiraiRobotStar 37 | 38 | 39 | 40 | 41 | repackage 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-compiler-plugin 50 | 3.8.1 51 | 52 | true 53 | true 54 | 55 | /Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/bin/javac 56 | 57 | 58 | 59 | 60 | 61 | 62 | Robot-web 63 | Robot-core 64 | Robot-dao 65 | Robot-client 66 | 67 | 68 | 69 | 70 | 71 | nexus-aliyun 72 | nexus-aliyun 73 | http://maven.aliyun.com/nexus/content/groups/public/ 74 | 75 | true 76 | 77 | 78 | false 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | net.mamoe 88 | mirai-core-jvm 89 | 2.6.4 90 | 91 | 92 | org.jetbrains.kotlinx 93 | kotlinx-coroutines-core 94 | 1.3.3 95 | 96 | 97 | 98 | 99 | org.springframework.boot 100 | spring-boot-starter 101 | 102 | 103 | org.springframework.boot 104 | spring-boot-starter-web 105 | 106 | 107 | 108 | org.mybatis.spring.boot 109 | mybatis-spring-boot-starter 110 | ${mybasitVersion} 111 | 112 | 113 | 114 | org.projectlombok 115 | lombok 116 | 117 | 118 | 119 | com.google.code.gson 120 | gson 121 | 2.8.6 122 | 123 | 124 | 125 | mysql 126 | mysql-connector-java 127 | ${mysqlConnectorVersion} 128 | 129 | 130 | 131 | com.alibaba 132 | druid 133 | ${druidVersion} 134 | 135 | 136 | 137 | net.sourceforge.htmlunit 138 | htmlunit 139 | ${htmlunitVersion} 140 | 141 | 142 | 143 | org.jsoup 144 | jsoup 145 | ${jsoupVersion} 146 | 147 | 148 | 149 | org.jetbrains.kotlin 150 | kotlin-stdlib 151 | 1.4.30 152 | 153 | 154 | 155 | gui.ava 156 | html2image 157 | 0.9 158 | 159 | 160 | 161 | com.google.guava 162 | guava 163 | 30.1-jre 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/autojob/CreeperTask.java: -------------------------------------------------------------------------------- 1 | //package com.hyq.robot.autojob; 2 | // 3 | //import com.hyq.robot.DO.BarPostDO; 4 | //import com.hyq.robot.DO.InformRelationDO; 5 | //import com.hyq.robot.DO.PostLinkDO; 6 | //import com.hyq.robot.constants.CommonConstant; 7 | //import com.hyq.robot.dao.BarPostDAO; 8 | //import com.hyq.robot.dao.InformRelationDAO; 9 | //import com.hyq.robot.dao.PostLinkDAO; 10 | //import com.hyq.robot.utils.TieBaUtil; 11 | //import com.hyq.robot.helper.SendHelper; 12 | //import com.hyq.robot.query.BarPostQuery; 13 | //import com.hyq.robot.query.InformRelationQuery; 14 | //import com.hyq.robot.query.PostLinkQuery; 15 | //import com.hyq.robot.star.RobotStar; 16 | //import net.mamoe.mirai.message.data.Message; 17 | //import net.mamoe.mirai.message.data.PlainText; 18 | //import org.springframework.context.annotation.Configuration; 19 | //import org.springframework.scheduling.annotation.EnableScheduling; 20 | //import org.springframework.scheduling.annotation.Scheduled; 21 | //import org.springframework.util.CollectionUtils; 22 | // 23 | //import javax.annotation.Resource; 24 | //import java.util.ArrayList; 25 | //import java.util.List; 26 | //import java.util.Map; 27 | //import java.util.stream.Collectors; 28 | // 29 | ///** 30 | // * @author nanke 31 | // * @date 2020/4/5 上午12:14 32 | // */ 33 | //@Configuration 34 | //@EnableScheduling 35 | //public class CreeperTask { 36 | // 37 | // @Resource 38 | // private PostLinkDAO postLinkDAO; 39 | // @Resource 40 | // private InformRelationDAO informRelationDAO; 41 | // @Resource 42 | // private BarPostDAO barPostDao; 43 | // 44 | // @Scheduled(cron = "0 0/1 * * * ? ") 45 | // public void task() { 46 | // 47 | // List postLinkDOS = postLinkDAO.queryByCondition(new PostLinkQuery()); 48 | // 49 | // for (PostLinkDO postLinkDO : postLinkDOS) { 50 | // String linkUrl = postLinkDO.getLinkUrl(); 51 | // try { 52 | // // 获取最大楼层 53 | // Long maxPageNo = TieBaUtil.queryPageNo(linkUrl,null,null); 54 | // // 落库最大楼层 55 | // BarPostQuery barPostQuery = BarPostQuery.builder().postUrl(linkUrl).build(); 56 | // List maxFloorIdDOS = barPostDao.queryByCondition(barPostQuery); 57 | // // 5页一爬 58 | // int pageNo = CollectionUtils.isEmpty(maxFloorIdDOS) ? 1 :maxFloorIdDOS.get(0).getPageNo(); 59 | // int stopPageNo = pageNo + 5 > maxPageNo ? maxPageNo.intValue() : pageNo + 5; 60 | // // 获取入库数据 61 | // List messageList = fallLibrary(pageNo,stopPageNo,linkUrl,null,null) 62 | // .stream() 63 | // .map(e -> "【" + postLinkDO.getAreaName() + "】" + e.getFloorId() + "楼:" + e.getContent()) 64 | // .map(PlainText::new) 65 | // .collect(Collectors.toList()); 66 | // // 获取播报订阅群 67 | // InformRelationQuery informRelationQuery = new InformRelationQuery(); 68 | // informRelationQuery.setPostLinkId(postLinkDO.getId()); 69 | // List informRelationDOS = informRelationDAO.queryByCondition(informRelationQuery); 70 | // // 广播 71 | // List groupIdList = informRelationDOS.stream().map(InformRelationDO::getGroupId).collect(Collectors.toList()); 72 | // SendHelper.sendGroupBatch(RobotStar.bot,groupIdList,messageList); 73 | // } catch (Exception e) { 74 | // SendHelper.sendSing(RobotStar.bot.getFriend(CommonConstant.errorSendId),new PlainText("帖子[" + linkUrl +"]定时任务爬取失败" + e)); 75 | // } 76 | // } 77 | // } 78 | // 79 | // /** 80 | // * 单条帖子多页爬取落库 81 | // * @param pageNo 82 | // * @param stopPageNo 83 | // * @param postUrl 84 | // */ 85 | // private List fallLibrary(int pageNo, int stopPageNo, String postUrl, String host, Integer port) { 86 | // 87 | // List result = new ArrayList<>(); 88 | // for (int i = pageNo; i <= stopPageNo; i++) { 89 | // // 当前页发言数据 90 | // Map> baseMap = TieBaUtil.handle(postUrl + "?pn=" + i,host,port); 91 | // List contentList = baseMap.get("contentList"); 92 | // List floorList = baseMap.get("floorList"); 93 | // // 过滤已经入库的 94 | // List dos = filter(wrapDO(i, postUrl,contentList, floorList)); 95 | // if (!CollectionUtils.isEmpty(dos)) 96 | // barPostDao.insertBatch(dos); 97 | // result.addAll(dos); 98 | // } 99 | // return result; 100 | // } 101 | // 102 | // /** 103 | // * 过滤楼层入库最高楼层 104 | // * @param barPostDOS 105 | // * @return 106 | // */ 107 | // private List filter(List barPostDOS) { 108 | // 109 | // if (CollectionUtils.isEmpty(barPostDOS)) 110 | // return new ArrayList<>(); 111 | // // 过滤已经入库的 112 | // BarPostQuery query = BarPostQuery.builder().postUrl(barPostDOS.get(0).getPostUrl()).build(); 113 | // List dos = barPostDao.queryByCondition(query); 114 | // if (CollectionUtils.isEmpty(dos)) { 115 | // return barPostDOS; 116 | // } 117 | // Long floorId = dos.get(0).getFloorId(); 118 | // return barPostDOS.stream().filter(barPostDO -> barPostDO.getFloorId() > floorId).collect(Collectors.toList()); 119 | // } 120 | // 121 | // /** 122 | // * 包装入库信息 123 | // * @return 124 | // */ 125 | // private List wrapDO(Integer pageNo, String postUrl, List contentList, List floorList) { 126 | // 127 | // List result = new ArrayList<>(); 128 | // for (int i = 0; i < contentList.size() && i < floorList.size(); i++) { 129 | // 130 | // String content = (String) contentList.get(i); 131 | // if (!TieBaUtil.messageFilter(content)) { 132 | // continue; 133 | // } 134 | // 135 | // BarPostDO barPostDO = new BarPostDO(); 136 | // barPostDO.setPostUrl(postUrl); 137 | // barPostDO.setFloorId((Long) floorList.get(i)); 138 | // barPostDO.setContent((String) contentList.get(i)); 139 | // barPostDO.setPageNo(pageNo); 140 | // result.add(barPostDO); 141 | // } 142 | // return result; 143 | // } 144 | //} 145 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/utils/GroupMemberUtil.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.utils; 2 | 3 | import com.hyq.robot.DO.TeamMemberDO; 4 | import com.hyq.robot.constants.CommonConstant; 5 | import org.springframework.util.CollectionUtils; 6 | 7 | import java.util.ArrayList; 8 | import java.util.Arrays; 9 | import java.util.List; 10 | import java.util.stream.Collectors; 11 | 12 | /** 13 | * @author nanke 14 | * @date 2020/7/22 下午7:49 15 | */ 16 | public class GroupMemberUtil { 17 | 18 | public static ArrayList locationList = new ArrayList<>( 19 | Arrays.asList( 20 | 11L,12L,13L,14L,15L, 21 | 21L,22L,23L,24L,25L, 22 | 31L,32L,33L,34L,35L, 23 | 41L,42L,43L,44L,45L, 24 | 51L,52L,53L,54L,55L)); 25 | 26 | public static ArrayList waiGongList = new ArrayList<>( 27 | Arrays.asList( 28 | 11L,12L,13L,14L,15L, 29 | 21L,22L,23L,24L,25L)); 30 | 31 | public static ArrayList neiGongList = new ArrayList<>( 32 | Arrays.asList( 33 | 31L,32L,33L,34L,35L, 34 | 41L,42L,43L,44L,45L)); 35 | 36 | public static ArrayList naiMaList = new ArrayList<>( 37 | Arrays.asList( 38 | 44L,45L,54L,55L)); 39 | 40 | public static ArrayList tanKeList = new ArrayList<>( 41 | Arrays.asList( 42 | 51L,52L,53L)); 43 | 44 | /** 45 | * 根据团队成员替换HTML中初始元素 46 | * @param teamName 47 | * @param memberDOS 48 | * @return 49 | */ 50 | public static String replaceMember(String teamName,List memberDOS) { 51 | String originStr = CommonConstant.htmlStr.replace("开团标题",teamName); 52 | for (TeamMemberDO memberDO : memberDOS) { 53 | originStr = originStr 54 | .replace("图片" + memberDO.getLocation(),memberDO.getColor()) 55 | .replace("成员" + memberDO.getLocation(),memberDO.getMemberName()); 56 | } 57 | String htmlStr = replaceInit(teamName, originStr); 58 | return htmlStr; 59 | } 60 | 61 | /** 62 | * 替换海报中所有初始值 63 | * @param teamName 64 | * @return 65 | */ 66 | public static String replaceInit(String teamName, String htmlStr) { 67 | 68 | return htmlStr 69 | .replace("开团标题",teamName) 70 | 71 | .replace("成员11","") 72 | .replace("图片11",CommonConstant.blankImg) 73 | .replace("成员12","") 74 | .replace("图片12",CommonConstant.blankImg) 75 | .replace("成员13","") 76 | .replace("图片13",CommonConstant.blankImg) 77 | .replace("成员14","") 78 | .replace("图片14",CommonConstant.blankImg) 79 | .replace("成员15","") 80 | .replace("图片15",CommonConstant.blankImg) 81 | 82 | .replace("成员21","") 83 | .replace("图片21",CommonConstant.blankImg) 84 | .replace("成员22","") 85 | .replace("图片22",CommonConstant.blankImg) 86 | .replace("成员23","") 87 | .replace("图片23",CommonConstant.blankImg) 88 | .replace("成员24","") 89 | .replace("图片24",CommonConstant.blankImg) 90 | .replace("成员25","") 91 | .replace("图片25",CommonConstant.blankImg) 92 | 93 | .replace("成员31","") 94 | .replace("图片31",CommonConstant.blankImg) 95 | .replace("成员32","") 96 | .replace("图片32",CommonConstant.blankImg) 97 | .replace("成员33","") 98 | .replace("图片33",CommonConstant.blankImg) 99 | .replace("成员34","") 100 | .replace("图片34",CommonConstant.blankImg) 101 | .replace("成员35","") 102 | .replace("图片35",CommonConstant.blankImg) 103 | 104 | .replace("成员41","") 105 | .replace("图片41",CommonConstant.blankImg) 106 | .replace("成员42","") 107 | .replace("图片42",CommonConstant.blankImg) 108 | .replace("成员43","") 109 | .replace("图片43",CommonConstant.blankImg) 110 | .replace("成员44","") 111 | .replace("图片44",CommonConstant.blankImg) 112 | .replace("成员45","") 113 | .replace("图片45",CommonConstant.blankImg) 114 | 115 | .replace("成员51","") 116 | .replace("图片51",CommonConstant.blankImg) 117 | .replace("成员52","") 118 | .replace("图片52",CommonConstant.blankImg) 119 | .replace("成员53","") 120 | .replace("图片53",CommonConstant.blankImg) 121 | .replace("成员54","") 122 | .replace("图片54",CommonConstant.blankImg) 123 | .replace("成员55","") 124 | .replace("图片55",CommonConstant.blankImg); 125 | } 126 | 127 | /** 128 | * 检查输入位置是否正确 129 | * @param location 130 | * @return 131 | */ 132 | public static boolean checkLocation(Long location) { 133 | return location == null || locationList.contains(location); 134 | } 135 | 136 | /** 137 | * 随机获取一个位置 138 | * @param list 139 | * @return 140 | */ 141 | public static Long getLocation(List list, String type) { 142 | 143 | if (type.equalsIgnoreCase("外功")) { 144 | List collect = waiGongList.stream().filter(e -> !list.contains(e)).collect(Collectors.toList()); 145 | if (!CollectionUtils.isEmpty(collect)) { 146 | return collect.get(0); 147 | } 148 | } else if (type.equalsIgnoreCase("内功")) { 149 | List collect = neiGongList.stream().filter(e -> !list.contains(e)).collect(Collectors.toList()); 150 | if (!CollectionUtils.isEmpty(collect)) { 151 | return collect.get(0); 152 | } 153 | } else if (type.equalsIgnoreCase("奶妈")) { 154 | List collect = naiMaList.stream().filter(e -> !list.contains(e)).collect(Collectors.toList()); 155 | if (!CollectionUtils.isEmpty(collect)) { 156 | return collect.get(0); 157 | } 158 | } else if (type.equalsIgnoreCase("坦克")) { 159 | List collect = tanKeList.stream().filter(e -> !list.contains(e)).collect(Collectors.toList()); 160 | if (!CollectionUtils.isEmpty(collect)) { 161 | return collect.get(0); 162 | } 163 | } 164 | 165 | List collect = locationList.stream().filter(e -> !list.contains(e)).collect(Collectors.toList()); 166 | if (!CollectionUtils.isEmpty(collect)) { 167 | return collect.get(0); 168 | } 169 | return null; 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /Robot-core/src/main/java/com/hyq/robot/constants/CommonConstant.java: -------------------------------------------------------------------------------- 1 | package com.hyq.robot.constants; 2 | 3 | /** 4 | * @author nanke 5 | * @date 2020/4/2 下午9:01 6 | */ 7 | public interface CommonConstant { 8 | 9 | /** 10 | * 机器人账号 11 | */ 12 | Long robotQQ = 430287797L; 13 | /** 14 | * 机器人密码 15 | */ 16 | String robotPassword = ""; 17 | /** 18 | * 通知QQ群 19 | */ 20 | Long selectGroupId = 839762931L; 21 | /** 22 | * 空白图片 23 | */ 24 | String blankImg = "https://qm-oss.oss-cn-hangzhou.aliyuncs.com/cmall/ba7d9112-eb2b-4efc-862a-77cb7d2d6373.png"; 25 | /** 26 | * 排期HTML 27 | */ 28 | String htmlStr = "\n" + 29 | "\n" + 30 | "\n" + 31 | "\n" + 32 | " \n" + 33 | " \n" + 63 | "\n" + 64 | " ?????????????\n" + 65 | "\n" + 66 | "\n" + 67 | "\n" + 68 | "
\n" + 69 | " \n" + 70 | " \n" + 71 | " \n" + 72 | " \n" + 73 | " \n" + 74 | " \n" + 75 | " \n" + 81 | " \n" + 87 | " \n" + 93 | " \n" + 99 | " \n" + 105 | " \n" + 106 | " \n" + 107 | " \n" + 113 | " \n" + 119 | " \n" + 125 | " \n" + 131 | " \n" + 137 | " \n" + 138 | " \n" + 139 | " \n" + 145 | " \n" + 151 | " \n" + 157 | " \n" + 163 | " \n" + 169 | " \n" + 170 | " \n" + 171 | " \n" + 177 | " \n" + 183 | " \n" + 189 | " \n" + 195 | " \n" + 201 | " \n" + 202 | " \n" + 203 | " \n" + 209 | " \n" + 215 | " \n" + 221 | " \n" + 227 | " \n" + 233 | " \n" + 234 | "
开团标题
一队二队三队四队五队
\n" + 76 | "
\n" + 77 | " \n" + 78 | "
\n" + 79 | " 成员11\n" + 80 | "
\n" + 82 | "
\n" + 83 | " \n" + 84 | "
\n" + 85 | " 成员21\n" + 86 | "
\n" + 88 | "
\n" + 89 | " \n" + 90 | "
\n" + 91 | " 成员31\n" + 92 | "
\n" + 94 | "
\n" + 95 | " \n" + 96 | "
\n" + 97 | " 成员41\n" + 98 | "
\n" + 100 | "
\n" + 101 | " \n" + 102 | "
\n" + 103 | " 成员51\n" + 104 | "
\n" + 108 | "
\n" + 109 | " \n" + 110 | "
\n" + 111 | " 成员12\n" + 112 | "
\n" + 114 | "
\n" + 115 | " \n" + 116 | "
\n" + 117 | " 成员22\n" + 118 | "
\n" + 120 | "
\n" + 121 | " \n" + 122 | "
\n" + 123 | " 成员32\n" + 124 | "
\n" + 126 | "
\n" + 127 | " \n" + 128 | "
\n" + 129 | " 成员42\n" + 130 | "
\n" + 132 | "
\n" + 133 | " \n" + 134 | "
\n" + 135 | " 成员52\n" + 136 | "
\n" + 140 | "
\n" + 141 | " \n" + 142 | "
\n" + 143 | " 成员13\n" + 144 | "
\n" + 146 | "
\n" + 147 | " \n" + 148 | "
\n" + 149 | " 成员23\n" + 150 | "
\n" + 152 | "
\n" + 153 | " \n" + 154 | "
\n" + 155 | " 成员33\n" + 156 | "
\n" + 158 | "
\n" + 159 | " \n" + 160 | "
\n" + 161 | " 成员43\n" + 162 | "
\n" + 164 | "
\n" + 165 | " \n" + 166 | "
\n" + 167 | " 成员53\n" + 168 | "
\n" + 172 | "
\n" + 173 | " \n" + 174 | "
\n" + 175 | " 成员14\n" + 176 | "
\n" + 178 | "
\n" + 179 | " \n" + 180 | "
\n" + 181 | " 成员24\n" + 182 | "
\n" + 184 | "
\n" + 185 | " \n" + 186 | "
\n" + 187 | " 成员34\n" + 188 | "
\n" + 190 | "
\n" + 191 | " \n" + 192 | "
\n" + 193 | " 成员44\n" + 194 | "
\n" + 196 | "
\n" + 197 | " \n" + 198 | "
\n" + 199 | " 成员54\n" + 200 | "
\n" + 204 | "
\n" + 205 | " \n" + 206 | "
\n" + 207 | " 成员15\n" + 208 | "
\n" + 210 | "
\n" + 211 | " \n" + 212 | "
\n" + 213 | " 成员25\n" + 214 | "
\n" + 216 | "
\n" + 217 | " \n" + 218 | "
\n" + 219 | " 成员35\n" + 220 | "
\n" + 222 | "
\n" + 223 | " \n" + 224 | "
\n" + 225 | " 成员45\n" + 226 | "
\n" + 228 | "
\n" + 229 | " \n" + 230 | "
\n" + 231 | " 成员55\n" + 232 | "
\n" + 235 | "
\n" + 236 | "\n" + 237 | ""; 238 | 239 | } 240 | --------------------------------------------------------------------------------