Skip to content

Commit

Permalink
增加了全局webhook,使用json传入webhook配置
Browse files Browse the repository at this point in the history
  • Loading branch information
wyt1215819315 committed Oct 5, 2021
1 parent 78eafab commit a90c3d0
Show file tree
Hide file tree
Showing 68 changed files with 1,708 additions and 697 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# AutoPlan_Helper
这是一个自动化的托管系统,目前支持网易云签到刷歌,bilibili,米游社原神签到
这是一个自动化的托管系统,目前支持网易云签到刷歌,bilibili赚经验+自动赛事预测,米游社原神签到,部署至服务器和你的小伙伴一起赚经验吧

目前项目属于测试阶段,可能会有些莫名其妙的bug,敬请谅解

Expand Down Expand Up @@ -101,8 +101,8 @@ mybatis:

### 未来
1. 管理员功能:查看日志,删除任务等
2. 统一推送,即不用填写多个,仅需在个人中心绑定一个即可
4. 手动执行b站任务
2. go-cqhttp推送(需要加机器人为好友)
3. 手动执行b站任务(咕咕咕)

### 更新日志
* 21.8.29 更新了b站二维码登录以及任务删除功能
Expand All @@ -116,6 +116,8 @@ mybatis:
* 21.9.15 尝试更新了BILIBILI-HELPER至1.1.5,可以改善部分任务中出现的null错误
* 21.10.1 layui已下线,目前将所有cdn服务换为本地文件
* 21.10.3 修复了部分bug,更改了部分数据表字段名称使其更统一,增加bilibili反向赛事预测
* 21.10.4 增加了全局webhook,更改webhook的传入方式为json字符串,增加生成器页面用来生成webhook.json


### 鸣谢
1. <a href="https://github.com/JunzhouLiu/BILIBILI-HELPER-PRE">BILIBILI-HELPER-PRE</a>
Expand Down
28 changes: 21 additions & 7 deletions auto_plan.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Target Server Version : 80018
File Encoding : 65001
Date: 02/10/2021 23:48:21
Date: 04/10/2021 21:57:58
*/

SET NAMES utf8mb4;
Expand Down Expand Up @@ -50,7 +50,7 @@ CREATE TABLE `auto_bilibili` (
PRIMARY KEY (`id`) USING BTREE,
INDEX `userid`(`userid`) USING BTREE,
CONSTRAINT `auto_bilibili_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `sys_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for auto_log
Expand All @@ -69,7 +69,7 @@ CREATE TABLE `auto_log` (
PRIMARY KEY (`id`) USING BTREE,
INDEX `userid`(`userid`) USING BTREE,
CONSTRAINT `auto_log_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `sys_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 106 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
) ENGINE = InnoDB AUTO_INCREMENT = 105 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for auto_mihayou
Expand All @@ -94,7 +94,7 @@ CREATE TABLE `auto_mihayou` (
UNIQUE INDEX `suid`(`suid`) USING BTREE,
INDEX `user_id`(`user_id`) USING BTREE,
CONSTRAINT `auto_mihayou_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for auto_netmusic
Expand Down Expand Up @@ -122,7 +122,7 @@ CREATE TABLE `auto_netmusic` (
UNIQUE INDEX `netmusic_id`(`netmusic_id`) USING BTREE,
INDEX `userid`(`userid`) USING BTREE,
CONSTRAINT `auto_netmusic_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `sys_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for bili_user
Expand All @@ -147,7 +147,7 @@ CREATE TABLE `bili_user` (
UNIQUE INDEX `uid`(`uid`) USING BTREE,
INDEX `auto_id`(`auto_id`) USING BTREE,
CONSTRAINT `bili_user_ibfk_1` FOREIGN KEY (`auto_id`) REFERENCES `auto_bilibili` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_role
Expand All @@ -174,7 +174,7 @@ CREATE TABLE `sys_role_user` (
`sys_user_id` int(11) NULL DEFAULT NULL,
`sys_role_id` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `sys_user_id`(`sys_user_id`) USING BTREE,
UNIQUE INDEX `sys_user_id`(`sys_user_id`) USING BTREE,
INDEX `sys_role_id`(`sys_role_id`) USING BTREE,
CONSTRAINT `sys_role_user_ibfk_1` FOREIGN KEY (`sys_user_id`) REFERENCES `sys_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `sys_role_user_ibfk_2` FOREIGN KEY (`sys_role_id`) REFERENCES `sys_role` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
Expand All @@ -194,6 +194,20 @@ CREATE TABLE `sys_user` (
UNIQUE INDEX `username`(`username`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_user_info
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_info`;
CREATE TABLE `sys_user_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`webhook` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`other` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `user_id`(`user_id`) USING BTREE,
CONSTRAINT `sys_user_info_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_sys_quartz_job
-- ----------------------------
Expand Down
15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,21 @@
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.flywaydb</groupId>-->
<!-- <artifactId>flyway-core</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>io.github.itning</groupId>
<artifactId>guava-retrying3</artifactId>
<version>3.0.1</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand Down
67 changes: 5 additions & 62 deletions src/main/java/com/misec/BiliMain.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.misec;

import com.misec.config.ConfigLoader;
import com.oldwu.log.OldwuLog;
import com.push.ServerPush;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.misec.config.Config;
import com.misec.login.ServerVerify;
import com.misec.login.Verify;
import com.misec.org.slf4j.impl.StaticLoggerBinder;
import com.misec.task.DailyTask;
import com.oldwu.log.OldwuLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -43,11 +40,11 @@ public static void main(String[] args) {
strings[0] = "";
strings[1] = "";
strings[2] = "";
run(strings,0,1);
run(strings, 0);
System.err.println(OldwuLog.getLog());
}

public static void run(String[] args,int autoId,int userId) {
public static void run(String[] args, int autoId) {

if (args.length < 3) {
OldwuLog.log("任务启动失败,cookie参数缺失!");
Expand All @@ -58,66 +55,12 @@ public static void run(String[] args,int autoId,int userId) {
//读取环境变量
Verify.verifyInit(args[0], args[1], args[2]);

if (args.length > 4) {
ServerVerify.verifyInit(args[3], args[4]);
} else if (args.length > 3) {
ServerVerify.verifyInit(args[3]);
}else {
ServerVerify.verifyInit(null, null);
}

//每日任务65经验
ConfigLoader.configInit(autoId);
if (!Boolean.TRUE.equals(ConfigLoader.getTaskConfig().getSkipDailyTask())) {
DailyTask dailyTask = new DailyTask();
dailyTask.doDailyTask();
} else {
OldwuLog.log("已开启了跳过本日任务,本日任务跳过(不会发起任何网络请求),如果需要取消跳过,请将skipDailyTask值改为false");
log.info("已开启了跳过本日任务,本日任务跳过(不会发起任何网络请求),如果需要取消跳过,请将skipDailyTask值改为false");
ServerPush.doServerPush(OldwuLog.getLog(),ServerVerify.getFtKey());
}
}

// /**
// * 用于腾讯云函数触发
// */
// public static void mainHandler(KeyValueClass ignored) {
// StaticLoggerBinder.LOG_IMPL = StaticLoggerBinder.LogImpl.JUL;
// String config = System.getProperty("config");
// if (null == config) {
// System.out.println("取config配置为空!!!");
// return;
// }
// KeyValueClass kv;
// try {
// kv = new Gson().fromJson(config, KeyValueClass.class);
// } catch (JsonSyntaxException e) {
// System.out.println("JSON配置反序列化失败,请检查");
// e.printStackTrace();
// return;
// }
// /**
// * 读取环境变量
// */
// Verify.verifyInit(kv.getDedeuserid(), kv.getSessdata(), kv.getBiliJct());
//
// if (null != kv.getTelegrambottoken() && null != kv.getTelegramchatid()) {
// ServerVerify.verifyInit(kv.getTelegrambottoken(), kv.getTelegramchatid());
// } else if (null != kv.getServerpushkey()) {
// ServerVerify.verifyInit(kv.getServerpushkey());
// }
//
//
// VersionInfo.printVersionInfo();
// //每日任务65经验
// Config.getInstance().configInit(new Gson().toJson(kv));
// if (!Boolean.TRUE.equals(Config.getInstance().getSkipDailyTask())) {
// DailyTask dailyTask = new DailyTask();
// dailyTask.doDailyTask();
// } else {
// log.info("已开启了跳过本日任务,本日任务跳过(不会发起任何网络请求),如果需要取消跳过,请将skipDailyTask值改为false");
// ServerPush.doServerPush();
// }
// }

}
6 changes: 4 additions & 2 deletions src/main/java/com/misec/apiquery/ApiList.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class ApiList {
* 直播签到.
*/
public static final String LIVE_CHECKING = "https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign";
public static final String SERVER_PUSH = "https://sc.ftqq.com/";
public static final String PUSH_PLUS = "https://www.pushplus.plus/send";
public static final String SERVER_PUSH = "https://sc.ftqq.com/";
public static final String SERVER_PUSH_V2 = "https://sctapi.ftqq.com/";
public static final String SERVER_PUSH_TELEGRAM = "https://api.telegram.org/bot";
public static final String LOGIN = "https://api.bilibili.com/x/web-interface/nav";
Expand All @@ -24,6 +24,8 @@ public class ApiList {
public static final String GET_REGION_RANKING = "https://api.bilibili.com/x/web-interface/ranking/region";
public static final String REWARD = "https://api.bilibili.com/x/member/web/exp/reward";
public static final String WECHAT_PUSH = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=";
public static final String WECOM_APP_PUSH_GET_TOKEN = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
public static final String WECOM_APP_PUSH = "https://qyapi.weixin.qq.com/cgi-bin/message/send";
/**
* 查询获取已获取的投币经验.
*/
Expand Down Expand Up @@ -77,5 +79,5 @@ public class ApiList {
public static final String QUERY_QUESTIONS = "https://api.bilibili.com/x/esports/guess/collection/question";

public static final String QUERY_MATCH_INFO = "https://api.bilibili.com/x/esports/guess/collection/statis";
public static final String DO_ADD = "https://api.bilibili.com/x/esports/guess/add";
public static final String DO_MATCH_ADD = "https://api.bilibili.com/x/esports/guess/add";
}
19 changes: 10 additions & 9 deletions src/main/java/com/misec/apiquery/OftenApi.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package com.misec.apiquery;

import com.google.gson.JsonObject;
import com.misec.config.ConfigLoader;
import com.misec.login.Verify;
import com.misec.utils.HttpUtil;
import lombok.extern.log4j.Log4j2;
import com.misec.utils.HttpUtils;
import lombok.extern.slf4j.Slf4j;

/**
* 部分API简单封装.
*
* @author Junzhou Liu
* @since 2020/10/14 14:27
*/
@Log4j2
@Slf4j
public class OftenApi {

/**
* 返回主站查询到的硬币余额,查询失败返回0.0.
*/
public static Double getCoinBalance() {
JsonObject responseJson = HttpUtil.doGet(ApiList.GET_COIN_BALANCE);
JsonObject responseJson = HttpUtils.doGet(ApiList.GET_COIN_BALANCE);
int responseCode = responseJson.get("code").getAsInt();
JsonObject dataObject = responseJson.get("data").getAsJsonObject();
if (responseCode == 0) {
Expand All @@ -28,7 +29,7 @@ public static Double getCoinBalance() {
return dataObject.get("money").getAsDouble();
}
} else {
log.debug("请求硬币余额接口错误,请稍后重试。错误请求信息:{}", responseJson);
log.warn("请求硬币余额接口错误,请稍后重试。错误请求信息:{}", responseJson);
return 0.0;
}
}
Expand All @@ -39,7 +40,7 @@ public static Double getCoinBalance() {
public static void getVipPrivilege(int type) {
String requestBody = "type=" + type
+ "&csrf=" + Verify.getInstance().getBiliJct();
JsonObject jsonObject = HttpUtil.doPost(ApiList.VIP_PRIVILEGE_RECEIVE, requestBody);
JsonObject jsonObject = HttpUtils.doPost(ApiList.VIP_PRIVILEGE_RECEIVE, requestBody);
int responseCode = jsonObject.get("code").getAsInt();
if (responseCode == 0) {
if (type == 1) {
Expand All @@ -48,7 +49,7 @@ public static void getVipPrivilege(int type) {
log.info("领取大会员福利/权益成功");
}
} else {
log.debug("领取年度大会员每月赠送的B币券/大会员福利失败,原因: {}", jsonObject.get("message").getAsString());
log.warn("领取年度大会员每月赠送的B币券/大会员福利失败,原因: {}", jsonObject.get("message").getAsString());
}
}

Expand All @@ -60,7 +61,7 @@ public static void getVipPrivilege(int type) {
public static String getVideoTitle(String bvid) {
String title;
String urlParameter = "?bvid=" + bvid;
JsonObject jsonObject = HttpUtil.doGet(ApiList.VIDEO_VIEW + urlParameter);
JsonObject jsonObject = HttpUtils.doGet(ApiList.VIDEO_VIEW + urlParameter);

if (jsonObject.get("code").getAsInt() == 0) {
title = jsonObject.getAsJsonObject("data").getAsJsonObject("owner").get("name").getAsString() + ": ";
Expand All @@ -83,7 +84,7 @@ public static String getVideoTitle(String bvid) {
public static String queryUserNameByUid(String uid) {
String urlParameter = "?mid=" + uid + "&jsonp=jsonp";
String userName = "1";
JsonObject jsonObject = HttpUtil.doGet(ApiList.QUERY_USER_NAME + urlParameter);
JsonObject jsonObject = HttpUtils.doGet(ApiList.QUERY_USER_NAME + urlParameter);
if (jsonObject.get("code").getAsInt() == 0) {
userName = jsonObject.getAsJsonObject("data").get("name").getAsString();
} else {
Expand Down
Loading

0 comments on commit a90c3d0

Please sign in to comment.