diff --git a/apps/query.js b/apps/query.js
index 76cf83c..f3cc503 100644
--- a/apps/query.js
+++ b/apps/query.js
@@ -6,6 +6,9 @@ import config from "../model/index.js";
// 爬虫库
import puppeteer from "../../../lib/puppeteer/puppeteer.js";
import _ from "lodash";
+// http库
+import axios from "axios";
+import fs from "node:fs";
export class query extends plugin {
constructor() {
@@ -40,13 +43,17 @@ export class query extends plugin {
fnc: "hotSearch",
},
{
- reg: "#买家秀",
+ reg: "^#买家秀$",
fnc: "buyerShow",
},
{
reg: "^#(累了)$",
fnc: "cospro",
- }
+ },
+ {
+ reg: "^#青年大学习$",
+ fnc: "youthLearning",
+ },
],
});
this.catConfig = config.getConfig("query");
@@ -298,6 +305,109 @@ export class query extends plugin {
return true;
}
+ // 青年大学习
+ async youthLearning(e) {
+ await axios
+ .get(
+ "https://qczj.h5yunban.com/qczj-youth-learning/cgi-bin/common-api/course/current",
+ {
+ headers: {
+ "User-Agent":
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 Edg/95.0.1020.53",
+ },
+ }
+ )
+ .then(resp => {
+ // console.log(resp.data);
+ return resp.data.result.uri.replace("index.html", "m.html");
+ })
+ .then(async uri => {
+ axios
+ .get(uri, {
+ headers: {
+ "User-Agent":
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 Edg/95.0.1020.53",
+ },
+ })
+ .then(resp => {
+ const content = resp.data;
+ const resList = content.match(/
<\/div>/g);
+ const valueList = resList.map(item => {
+ return item.match(/data-a="(\d+)"/)[1];
+ });
+ let result = [];
+ for (let i = 0; i < valueList.length; i += 4) {
+ const group = valueList.slice(i, i + 4);
+ switch (group.join("")) {
+ case "2221":
+ result.push("D");
+ break;
+ case "1222":
+ result.push("A");
+ break;
+ case "2122":
+ result.push("B");
+ break;
+ case "2212":
+ result.push("C");
+ break;
+ case "1111":
+ result.push("ABCD");
+ break;
+ default:
+ result.push("");
+ break;
+ }
+ }
+ // 封装以下答案
+ let ans = "";
+ for (let i = 0; i < result.length; i++) {
+ ans += `${i + 1}. ${result[i]}\n`;
+ }
+ e.reply(ans);
+ const imgMatch =
+ "https://h5.cyol.com/special/daxuexi/fk2hp2n7xv/index.html".match(
+ /[^\/]+/g
+ );
+ const imgId = imgMatch[imgMatch.length - 2];
+
+ axios
+ .get(`https://h5.cyol.com/special/daxuexi/${imgId}/images/end.jpg`, {
+ headers: {
+ "User-Agent":
+ "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36",
+ },
+ responseType: "stream",
+ })
+ .then(resp => {
+ const filePath = "./youthLearning.png";
+ const writer = fs.createWriteStream(filePath);
+ resp.data.pipe(writer);
+ return new Promise((resolve, reject) => {
+ writer.on("finish", () => {
+ writer.close(() => {
+ resolve(filePath);
+ });
+ });
+ writer.on("error", err => {
+ fs.unlink(filePath, () => {
+ reject(err);
+ });
+ });
+ });
+ })
+ .then(filePath => {
+ e.reply(segment.image(fs.readFileSync(filePath)));
+ fs.unlinkSync(filePath, (err) => {
+ if (err) throw err;
+ console.error('删除青年大学习文件失败');
+ });
+ });
+ });
+ });
+ return true;
+ }
+
async cospro(e) {
let req = [
...(await fetch("https://imgapi.cn/cos2.php?return=jsonpro")
diff --git a/config/help.yaml b/config/help.yaml
index 0b1ae0e..445aec1 100644
--- a/config/help.yaml
+++ b/config/help.yaml
@@ -21,6 +21,9 @@
- icon: pic1
title: "#累了"
desc: 疲惫往往是过度劳累
+ - icon: youthLearning
+ title: "#青年大学习"
+ desc: 青年大学习答案和截图
- group: 工具类合集
list:
- icon: translate
diff --git a/img/help.jpg b/img/help.jpg
index fba212b..a4b46f7 100644
Binary files a/img/help.jpg and b/img/help.jpg differ
diff --git a/resources/img/icon/youthLearning.png b/resources/img/icon/youthLearning.png
new file mode 100644
index 0000000..40941f6
Binary files /dev/null and b/resources/img/icon/youthLearning.png differ