mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-23 03:20:52 +08:00
修正崩3接口补充自动签到
This commit is contained in:
parent
65ad5c203c
commit
0feabb76fb
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,3 +1,10 @@
|
|||||||
|
# 1.1.4
|
||||||
|
* 新增指令`#米游币全部签到`
|
||||||
|
*为所有存在的stoken进行社区米游币签到
|
||||||
|
* 新增指令`#米社全部签到`
|
||||||
|
*为所有用户进行其余的社区模块签到
|
||||||
|
* 新增自动签到默认**00:02**开始执行签到
|
||||||
|
*具体时间修改在`./config/config.yaml`
|
||||||
# 1.1.3
|
# 1.1.3
|
||||||
* 下列功能需要绑定`cookies`来跑,非信任的bot请勿发送cookies
|
* 下列功能需要绑定`cookies`来跑,非信任的bot请勿发送cookies
|
||||||
* 修正版本说明避免误导
|
* 修正版本说明避免误导
|
||||||
@ -17,12 +24,6 @@
|
|||||||
* 如果出现了安装其中一个包导致另外的包出问题的请群里询问
|
* 如果出现了安装其中一个包导致另外的包出问题的请群里询问
|
||||||
* 具体获取cookie教程后续会完善 敬情期待~
|
* 具体获取cookie教程后续会完善 敬情期待~
|
||||||
* 需要完整的cookie内容要包含`login_ticket`跟`login_uid`不然是无法实现米游社签到的
|
* 需要完整的cookie内容要包含`login_ticket`跟`login_uid`不然是无法实现米游社签到的
|
||||||
* 自动签到逻辑目前还在梳理中.....
|
|
||||||
|
|
||||||
# 1.1.1
|
|
||||||
* 初步兼容V3版本
|
|
||||||
* 版本兼容问题V2报错的话请导入`yaml`包 指令 `cnpm i yaml`
|
|
||||||
* V3版本请在cmd命令窗口追加`date-format`包 指令`pnpm i date-format`
|
|
||||||
|
|
||||||
# 1.1.0
|
# 1.1.0
|
||||||
* 增加`#图鉴帮助`用于查看帮助命令
|
* 增加`#图鉴帮助`用于查看帮助命令
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import lodash from "lodash";
|
import lodash from "lodash";
|
||||||
|
import schedule from "node-schedule";
|
||||||
import {
|
import {
|
||||||
AtlasAlias
|
AtlasAlias
|
||||||
} from "./xiaoyao_image.js";
|
} from "./xiaoyao_image.js";
|
||||||
@ -7,8 +8,10 @@ import {
|
|||||||
help
|
help
|
||||||
} from "./help.js";
|
} from "./help.js";
|
||||||
import {
|
import {
|
||||||
Note,DailyNoteTask,
|
Note,
|
||||||
Note_appoint,pokeNote
|
DailyNoteTask,
|
||||||
|
Note_appoint,
|
||||||
|
pokeNote
|
||||||
} from "./Note.js";
|
} from "./Note.js";
|
||||||
import {
|
import {
|
||||||
rule as adminRule,
|
rule as adminRule,
|
||||||
@ -21,18 +24,31 @@ import {
|
|||||||
} from "../components/Changelog.js";
|
} from "../components/Changelog.js";
|
||||||
import {
|
import {
|
||||||
rule as signRule,
|
rule as signRule,
|
||||||
sign,mysSign,cookiesDocHelp
|
sign,
|
||||||
|
mysSign,
|
||||||
|
cookiesDocHelp,
|
||||||
|
allMysSign,
|
||||||
|
allSign
|
||||||
} from "./sign.js"
|
} from "./sign.js"
|
||||||
export {
|
export {
|
||||||
updateRes,
|
updateRes,
|
||||||
updateMiaoPlugin,sign,
|
updateMiaoPlugin,
|
||||||
|
sign,
|
||||||
versionInfo,
|
versionInfo,
|
||||||
Note_appoint,pokeNote,cookiesDocHelp,
|
Note_appoint,
|
||||||
|
pokeNote,
|
||||||
|
cookiesDocHelp,
|
||||||
sysCfg,
|
sysCfg,
|
||||||
help,DailyNoteTask,
|
help,
|
||||||
|
DailyNoteTask,
|
||||||
|
allMysSign,
|
||||||
|
allSign,
|
||||||
AtlasAlias,
|
AtlasAlias,
|
||||||
Note,mysSign
|
Note,
|
||||||
|
mysSign
|
||||||
};
|
};
|
||||||
|
import gsCfg from '../model/gsCfg.js';
|
||||||
|
const _path = process.cwd();
|
||||||
|
|
||||||
let rule = {
|
let rule = {
|
||||||
versionInfo: {
|
versionInfo: {
|
||||||
@ -68,6 +84,15 @@ lodash.forEach(rule, (r) => {
|
|||||||
r.prehash = true;
|
r.prehash = true;
|
||||||
r.hashMark = true;
|
r.hashMark = true;
|
||||||
});
|
});
|
||||||
|
task();
|
||||||
|
//定时任务
|
||||||
|
async function task() {
|
||||||
|
if (typeof test != "undefined") return;
|
||||||
|
let set = gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config")
|
||||||
|
schedule.scheduleJob(set.mysBbsTime, () => allMysSign());
|
||||||
|
schedule.scheduleJob(set.allSignTime, () => allSign());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
rule
|
rule
|
||||||
|
210
apps/sign.js
210
apps/sign.js
@ -11,6 +11,7 @@ import {
|
|||||||
isV3
|
isV3
|
||||||
} from '../components/Changelog.js';
|
} from '../components/Changelog.js';
|
||||||
import gsCfg from '../model/gsCfg.js';
|
import gsCfg from '../model/gsCfg.js';
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
export const rule = {
|
export const rule = {
|
||||||
mysSign: {
|
mysSign: {
|
||||||
@ -18,9 +19,17 @@ export const rule = {
|
|||||||
describe: "米游社米游币签到(理论上会签到全部所以区分开了)"
|
describe: "米游社米游币签到(理论上会签到全部所以区分开了)"
|
||||||
},
|
},
|
||||||
sign: {
|
sign: {
|
||||||
reg: "^#*(崩坏3|崩坏2|未定事件簿|大别野|崩坏星穹铁道|绝区零)签到$",
|
reg: "^#*(崩坏3|崩坏2|未定事件簿)签到$",
|
||||||
describe: "米社规则签到"
|
describe: "米社规则签到"
|
||||||
},
|
},
|
||||||
|
allMysSign: {
|
||||||
|
reg: "^#米游币全部签到$",
|
||||||
|
describe: "米游币全部签到"
|
||||||
|
},
|
||||||
|
allSign: {
|
||||||
|
reg: "^#米社全部签到$",
|
||||||
|
describe: "米社全部签到"
|
||||||
|
},
|
||||||
cookiesDocHelp: {
|
cookiesDocHelp: {
|
||||||
reg: "^#*(米游社|cookies|米游币)帮助$",
|
reg: "^#*(米游社|cookies|米游币)帮助$",
|
||||||
describe: "cookies获取帮助"
|
describe: "cookies获取帮助"
|
||||||
@ -37,23 +46,30 @@ const RETRY_OPTIONS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function sign(e) {
|
export async function sign(e) {
|
||||||
let isck=await cookie(e);
|
let {
|
||||||
if (!isck) {
|
skuid
|
||||||
|
} = await getCookie(e);
|
||||||
|
if (!skuid) {
|
||||||
|
e.reply("请先绑定cookie~\n发送【cookie帮助】获取教程")
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
START = moment().unix();
|
START = moment().unix();
|
||||||
let miHoYoApi = new MihoYoApi(e);
|
let miHoYoApi = new MihoYoApi(e);
|
||||||
let resultMessage="";
|
let resultMessage = "";
|
||||||
let msg = e.msg.replace(/#|签到|井|米游社|mys|社区/g, "");
|
let msg = e.msg.replace(/#|签到|井|米游社|mys|社区/g, "");
|
||||||
let ForumData = await getDataList(msg);
|
let ForumData = await getDataList(msg);
|
||||||
e.reply(`开始尝试${msg}签到预计${msg=='全部'?"60":"5-10"}秒~`)
|
e.reply(`开始尝试${msg}签到预计${msg=='全部'?"60":"5-10"}秒~`)
|
||||||
for (let forum of ForumData) {
|
for (let forum of ForumData) {
|
||||||
|
if (!(["崩坏3", "崩坏2", "未定事件簿"].includes(forum.name))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
resultMessage += `**${forum.name}**\n`
|
resultMessage += `**${forum.name}**\n`
|
||||||
try {
|
try {
|
||||||
// 1 BBS Sign
|
// 1 BBS Sign
|
||||||
let resObj = await promiseRetry((retry, number) => {
|
let resObj = await promiseRetry((retry, number) => {
|
||||||
Bot.logger.info(`开始签到: [${forum.name}] 尝试次数: ${number}`);
|
// Bot.logger.info(`开始签到: [${forum.name}] 尝试次数: ${number}`);
|
||||||
return miHoYoApi.honkai3rdSignTask(msg).catch((e) => {
|
return miHoYoApi.honkai3rdSignTask(forum.name).catch((e) => {
|
||||||
Bot.logger.error(`${forum.name} 签到失败: [${e.message}] 尝试次数: ${number}`);
|
Bot.logger.error(`${forum.name} 签到失败: [${e.message}] 尝试次数: ${number}`);
|
||||||
return retry(e);
|
return retry(e);
|
||||||
});
|
});
|
||||||
@ -67,23 +83,23 @@ export async function sign(e) {
|
|||||||
|
|
||||||
await utils.randomSleepAsync();
|
await utils.randomSleepAsync();
|
||||||
}
|
}
|
||||||
await replyMsg(e,resultMessage);
|
await replyMsg(e, resultMessage);
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
export async function mysSign(e) {
|
export async function mysSign(e) {
|
||||||
let isck=await cookie(e);
|
let isck = await cookie(e);
|
||||||
if (!isck) {
|
if (!isck) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let iscount="";
|
let iscount = "";
|
||||||
let miHoYoApi = new MihoYoApi(e);
|
let miHoYoApi = new MihoYoApi(e);
|
||||||
if(Object.keys((await miHoYoApi.getStoken(e.user_id))).length == 0){
|
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length == 0) {
|
||||||
e.reply("未读取到stoken请尝试重新登录获取cookies")
|
e.reply("未读取到stoken请尝试重新登录获取cookies")
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
START = moment().unix();
|
START = moment().unix();
|
||||||
let resultMessage="";
|
let resultMessage = "";
|
||||||
// Execute task
|
// Execute task
|
||||||
let msg = e.msg.replace(/#|签到|井|米游社|mys|社区/g, "");
|
let msg = e.msg.replace(/#|签到|井|米游社|mys|社区/g, "");
|
||||||
let ForumData = await getDataList(msg);
|
let ForumData = await getDataList(msg);
|
||||||
@ -93,7 +109,7 @@ export async function mysSign(e) {
|
|||||||
try {
|
try {
|
||||||
// 1 BBS Sign
|
// 1 BBS Sign
|
||||||
let resObj = await promiseRetry((retry, number) => {
|
let resObj = await promiseRetry((retry, number) => {
|
||||||
Bot.logger.info(`开始签到: [${forum.name}] 尝试次数: ${number}`);
|
// Bot.logger.info(`开始签到: [${forum.name}] 尝试次数: ${number}`);
|
||||||
return miHoYoApi.forumSign(forum.forumId).catch((e) => {
|
return miHoYoApi.forumSign(forum.forumId).catch((e) => {
|
||||||
Bot.logger.error(`${forum.name} 签到失败: [${e.message}] 尝试次数: ${number}`);
|
Bot.logger.error(`${forum.name} 签到失败: [${e.message}] 尝试次数: ${number}`);
|
||||||
return retry(e);
|
return retry(e);
|
||||||
@ -105,7 +121,6 @@ export async function mysSign(e) {
|
|||||||
Bot.logger.error(`${forum.name} 签到失败 [${e.message}]`);
|
Bot.logger.error(`${forum.name} 签到失败 [${e.message}]`);
|
||||||
resultMessage += `签到失败: [${e.message}]\n`;
|
resultMessage += `签到失败: [${e.message}]\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
await utils.randomSleepAsync();
|
await utils.randomSleepAsync();
|
||||||
}
|
}
|
||||||
for (let forum of ForumData) {
|
for (let forum of ForumData) {
|
||||||
@ -113,7 +128,7 @@ export async function mysSign(e) {
|
|||||||
try {
|
try {
|
||||||
// 2 BBS list post
|
// 2 BBS list post
|
||||||
let resObj = await promiseRetry((retry, number) => {
|
let resObj = await promiseRetry((retry, number) => {
|
||||||
Bot.logger.info(`读取帖子列表: [${forum.name}] 尝试次数: ${number}`);
|
// Bot.logger.info(`读取帖子列表: [${forum.name}] 尝试次数: ${number}`);
|
||||||
return miHoYoApi.forumPostList(forum.forumId).catch((e) => {
|
return miHoYoApi.forumPostList(forum.forumId).catch((e) => {
|
||||||
Bot.logger.error(`${forum.name} 读取帖子列表失败: [${e.message}] 尝试次数: ${number}`);
|
Bot.logger.error(`${forum.name} 读取帖子列表失败: [${e.message}] 尝试次数: ${number}`);
|
||||||
return retry(e);
|
return retry(e);
|
||||||
@ -126,31 +141,31 @@ export async function mysSign(e) {
|
|||||||
post = post.post;
|
post = post.post;
|
||||||
// 2.1 BBS read post
|
// 2.1 BBS read post
|
||||||
let resObj = await promiseRetry((retry, number) => {
|
let resObj = await promiseRetry((retry, number) => {
|
||||||
Bot.logger.info(`读取帖子: [${post.subject}] 尝试次数: ${number}`);
|
// Bot.logger.info(`读取帖子: [${post.subject}] 尝试次数: ${number}`);
|
||||||
return miHoYoApi.forumPostDetail(post['post_id']).catch((e) => {
|
return miHoYoApi.forumPostDetail(post['post_id']).catch((e) => {
|
||||||
Bot.logger.error(`${forum.name} 读取帖子失败: [${e.message}] 尝试次数: ${number}`);
|
Bot.logger.error(`${forum.name} 读取帖子失败: [${e.message}] 尝试次数: ${number}`);
|
||||||
return retry(e);
|
return retry(e);
|
||||||
});
|
});
|
||||||
}, RETRY_OPTIONS);
|
}, RETRY_OPTIONS);
|
||||||
Bot.logger.info(`${forum.name} [${post.subject}] 读取成功 [${resObj.message}]`);
|
// Bot.logger.info(`${forum.name} [${post.subject}] 读取成功 [${resObj.message}]`);
|
||||||
await utils.randomSleepAsync();
|
await utils.randomSleepAsync();
|
||||||
// 2.2 BBS vote post
|
// 2.2 BBS vote post
|
||||||
resObj = await promiseRetry((retry, number) => {
|
resObj = await promiseRetry((retry, number) => {
|
||||||
Bot.logger.info(`点赞帖子: [${post.subject}] 尝试次数: ${number}`);
|
// Bot.logger.info(`点赞帖子: [${post.subject}] 尝试次数: ${number}`);
|
||||||
return miHoYoApi.forumPostVote(post['post_id']).catch((e) => {
|
return miHoYoApi.forumPostVote(post['post_id']).catch((e) => {
|
||||||
Bot.logger.error(`${forum.name} 点赞帖子失败: [${e.message}] 尝试次数: ${number}`);
|
Bot.logger.error(`${forum.name} 点赞帖子失败: [${e.message}] 尝试次数: ${number}`);
|
||||||
return retry(e);
|
return retry(e);
|
||||||
});
|
});
|
||||||
}, RETRY_OPTIONS);
|
}, RETRY_OPTIONS);
|
||||||
|
|
||||||
Bot.logger.info(`${forum.name} [${post.subject}] 点赞成功 [${resObj.message}]`);
|
// Bot.logger.info(`${forum.name} [${post.subject}] 点赞成功 [${resObj.message}]`);
|
||||||
await utils.randomSleepAsync();
|
await utils.randomSleepAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.3 BBS share post
|
// 2.3 BBS share post
|
||||||
let sharePost = postList[0].post;
|
let sharePost = postList[0].post;
|
||||||
resObj = await promiseRetry((retry, number) => {
|
resObj = await promiseRetry((retry, number) => {
|
||||||
Bot.logger.info(`分享帖子: [${sharePost.subject}] 尝试次数: ${number}`);
|
// Bot.logger.info(`分享帖子: [${sharePost.subject}] 尝试次数: ${number}`);
|
||||||
return miHoYoApi.forumPostShare(sharePost['post_id']).catch((e) => {
|
return miHoYoApi.forumPostShare(sharePost['post_id']).catch((e) => {
|
||||||
Bot.logger.error(`${forum.name} 分享帖子失败: [${e.message}] 尝试次数: ${number}`);
|
Bot.logger.error(`${forum.name} 分享帖子失败: [${e.message}] 尝试次数: ${number}`);
|
||||||
return retry(e);
|
return retry(e);
|
||||||
@ -163,21 +178,21 @@ export async function mysSign(e) {
|
|||||||
resultMessage += `读帖点赞分享: 成功\n`;
|
resultMessage += `读帖点赞分享: 成功\n`;
|
||||||
await utils.randomSleepAsync();
|
await utils.randomSleepAsync();
|
||||||
}
|
}
|
||||||
await replyMsg(e,resultMessage);
|
await replyMsg(e, resultMessage);
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function replyMsg(e,resultMessage){
|
async function replyMsg(e, resultMessage) {
|
||||||
const END = moment().unix();
|
const END = moment().unix();
|
||||||
Bot.logger.info(`运行结束, 用时 ${END - START} 秒`);
|
Bot.logger.info(`运行结束, 用时 ${END - START} 秒`);
|
||||||
resultMessage += `\n用时 ${END - START} 秒`;
|
resultMessage += `\n用时 ${END - START} 秒`;
|
||||||
e.reply(resultMessage);
|
e.reply(resultMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDataList(name){
|
async function getDataList(name) {
|
||||||
let ForumData = Data.readJSON(`${_path}/plugins/xiaoyao-cvs-plugin/defSet/json`, "mys")
|
let ForumData = Data.readJSON(`${_path}/plugins/xiaoyao-cvs-plugin/defSet/json`, "mys")
|
||||||
for(let item of ForumData){
|
for (let item of ForumData) {
|
||||||
if(item.name==name){ //循环结束未找到的时候返回原数组签到全部
|
if (item.name == name) { //循环结束未找到的时候返回原数组签到全部
|
||||||
return [item]
|
return [item]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,34 +200,24 @@ async function getDataList(name){
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function cookie(e) {
|
async function cookie(e) {
|
||||||
let cookie, uid;
|
let {
|
||||||
|
cookie,
|
||||||
|
uid
|
||||||
|
} = await getCookie(e);
|
||||||
let miHoYoApi = new MihoYoApi(e);
|
let miHoYoApi = new MihoYoApi(e);
|
||||||
let skuid;
|
let skuid;
|
||||||
let cookiesDoc=await getcookiesDoc();
|
let cookiesDoc = await getcookiesDoc();
|
||||||
if (isV3) {
|
|
||||||
skuid= await gsCfg.getBingCookie(e.user_id);
|
if (!cookie) {
|
||||||
cookie = skuid.ck;
|
e.reply("cookie失效请重新绑定~【教程】\n" + cookiesDoc)
|
||||||
uid = skuid.item;
|
|
||||||
} else {
|
|
||||||
if (NoteCookie[e.user_id]) {
|
|
||||||
cookie = NoteCookie[e.user_id].cookie;
|
|
||||||
uid = NoteCookie[e.user_id].uid;
|
|
||||||
} else if (BotConfig.dailyNote && BotConfig.dailyNote[e.user_id]) {
|
|
||||||
cookie = BotConfig.dailyNote[e.user_id].cookie;
|
|
||||||
uid = BotConfig.dailyNote[e.user_id].uid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!cookie){
|
|
||||||
e.reply("cookie失效请重新绑定~【教程】\n"+cookiesDoc)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
e.uid = uid;
|
|
||||||
e.cookie=cookie;
|
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length != 0) {
|
||||||
if(Object.keys((await miHoYoApi.getStoken(e.user_id))).length != 0){
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!cookie.includes("login_ticket")&&(isV3&&!skuid?.login_ticket)) {
|
if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) {
|
||||||
e.reply("米游社登录cookie不完整,请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket【教程】 "+cookiesDoc)
|
e.reply("米游社登录cookie不完整,请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket【教程】 " + cookiesDoc)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let flot = (await miHoYoApi.stoken(cookie, e));
|
let flot = (await miHoYoApi.stoken(cookie, e));
|
||||||
@ -224,11 +229,114 @@ async function cookie(e) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
export async function cookiesDocHelp(e){
|
async function getCookie(e) {
|
||||||
let cookiesDoc=await getcookiesDoc()
|
let skuid, cookie, uid
|
||||||
e.reply("【cookies帮助】"+cookiesDoc+"\ncookies必须包含login_ticket获取后请私发机器人");
|
if (isV3) {
|
||||||
|
skuid = await gsCfg.getBingCookie(e.user_id);
|
||||||
|
cookie = skuid.ck;
|
||||||
|
uid = skuid.item;
|
||||||
|
} else {
|
||||||
|
if (NoteCookie[e.user_id]) {
|
||||||
|
cookie = NoteCookie[e.user_id].cookie;
|
||||||
|
uid = NoteCookie[e.user_id].uid;
|
||||||
|
skuid = NoteCookie[e.user_id];
|
||||||
|
} else if (BotConfig.dailyNote && BotConfig.dailyNote[e.user_id]) {
|
||||||
|
cookie = BotConfig.dailyNote[e.user_id].cookie;
|
||||||
|
uid = BotConfig.dailyNote[e.user_id].uid;
|
||||||
|
skuid = BotConfig.NoteCookie[e.user_id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e.uid = uid;
|
||||||
|
e.cookie = cookie;
|
||||||
|
return {
|
||||||
|
cookie,
|
||||||
|
uid,
|
||||||
|
skuid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export async function cookiesDocHelp(e) {
|
||||||
|
let cookiesDoc = await getcookiesDoc()
|
||||||
|
e.reply("【cookies帮助】" + cookiesDoc + "\ncookies必须包含login_ticket获取后请私发机器人");
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
async function getcookiesDoc(){
|
async function getcookiesDoc() {
|
||||||
return await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`,"config").cookiesDoc
|
return await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").cookiesDoc
|
||||||
|
}
|
||||||
|
//定时米社米币签到任务
|
||||||
|
export async function allMysSign() {
|
||||||
|
Bot.logger.mark(`开始米社签到任务`);
|
||||||
|
let stoken = await gsCfg.getBingStoken();
|
||||||
|
let isPushSign = await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").isPushSign
|
||||||
|
//获取需要签到的用户
|
||||||
|
for (let data of stoken) {
|
||||||
|
let user_id = data.qq;
|
||||||
|
Bot.logger.mark(`正在为qq${user_id}签到`);
|
||||||
|
let e = {
|
||||||
|
user_id,
|
||||||
|
isTask: true
|
||||||
|
};
|
||||||
|
e.cookie = `stuid=${data.stuid};stoken=${data.stoken};ltoken=${data.ltoken};`;
|
||||||
|
e.msg = "全部"
|
||||||
|
//已签到不重复执行
|
||||||
|
let key = `genshin:mys:signed_bbs:${user_id}`;
|
||||||
|
if (await redis.get(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.reply = (msg) => {
|
||||||
|
//关闭签到消息推送
|
||||||
|
if (!isPushSign) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.includes("签到成功") && (cookie.isSignPush === true || cookie.isSignPush === undefined)) {
|
||||||
|
// msg = msg.replace("签到成功", "自动签到成功");
|
||||||
|
utils.relpyPrivate(user_id, msg + "\n自动签到成功");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
await mysSign(e);
|
||||||
|
await utils.sleepAsync(10000);
|
||||||
|
}
|
||||||
|
Bot.logger.mark(`签到任务完成`);
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
//定时签到任务
|
||||||
|
export async function allSign() {
|
||||||
|
Bot.logger.mark(`开始米社签到任务`);
|
||||||
|
let isPushSign = await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").isAllSign
|
||||||
|
let userIdList = [];
|
||||||
|
if (isV3) {
|
||||||
|
let dir = './data/MysCookie/'
|
||||||
|
let files = fs.readdirSync(dir).filter(file => file.endsWith('.yaml'))
|
||||||
|
userIdList = (files.join(",").replace(/.yaml/g, "").split(","))
|
||||||
|
} else {
|
||||||
|
for (let [user_id, cookie] of Object.entries(NoteCookie)) {
|
||||||
|
userIdList.push(user_id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let qq of userIdList) {
|
||||||
|
let user_id = qq;
|
||||||
|
let e = {
|
||||||
|
user_id,
|
||||||
|
qq,
|
||||||
|
isTask: true
|
||||||
|
};
|
||||||
|
e.msg="全部"
|
||||||
|
e.reply = (msg) => {
|
||||||
|
if (!msg.includes("OK")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isAllSign) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (msg.includes("签到成功") && (cookie.isSignPush === true || cookie.isSignPush === undefined)) {
|
||||||
|
utils.relpyPrivate(qq, msg + "\n自动签到成功");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await sign(e);
|
||||||
|
await utils.sleepAsync(10000);
|
||||||
|
}
|
||||||
|
Bot.logger.mark(`签到任务完成`);
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,10 @@
|
|||||||
# cookies教程
|
# cookies教程
|
||||||
cookiesDoc: docs.qq.com/doc/DV2tDY2ltSFdtbU9z
|
cookiesDoc: docs.qq.com/doc/DV2tDY2ltSFdtbU9z
|
||||||
|
# 米币签到成功是否推送
|
||||||
|
isPushSign: false
|
||||||
|
# 米游社米币签到定时任务,Cron表达式,默认00:02开始执行签到
|
||||||
|
mysBbsTime: 0 2 0 * * ?
|
||||||
|
# 签到成功是否推送
|
||||||
|
isAllSign: false
|
||||||
|
# 米游社签到定时任务,Cron表达式,默认00:02开始执行签到
|
||||||
|
allSignTime: 0 2 0 * * ?
|
||||||
|
@ -133,7 +133,27 @@ class GsCfg {
|
|||||||
ckQQ
|
ckQQ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/** 读取所有用户绑定的stoken */
|
||||||
|
async getBingStoken() {
|
||||||
|
let ck = []
|
||||||
|
let ckQQ = {}
|
||||||
|
let dir = `plugins/${plugin}/data/yaml/`
|
||||||
|
let files = fs.readdirSync(dir).filter(file => file.endsWith('.yaml'))
|
||||||
|
|
||||||
|
const readFile = promisify(fs.readFile)
|
||||||
|
|
||||||
|
let promises = []
|
||||||
|
|
||||||
|
files.forEach((v) => promises.push(readFile(`${dir}${v}`, 'utf8')))
|
||||||
|
const res = await Promise.all(promises)
|
||||||
|
res.forEach((v,index) => {
|
||||||
|
let tmp = YAML.parse(v)
|
||||||
|
tmp["qq"]=files[index].split(".")[0]*1
|
||||||
|
ck.push(tmp)
|
||||||
|
|
||||||
|
})
|
||||||
|
return ck
|
||||||
|
}
|
||||||
getBingCkSingle(userId) {
|
getBingCkSingle(userId) {
|
||||||
let file = `./data/MysCookie/${userId}.yaml`
|
let file = `./data/MysCookie/${userId}.yaml`
|
||||||
try {
|
try {
|
||||||
|
@ -23,7 +23,7 @@ const boards = {
|
|||||||
forumid: 1,
|
forumid: 1,
|
||||||
key: 'honkai3rd',
|
key: 'honkai3rd',
|
||||||
biz: 'bh3_cn',
|
biz: 'bh3_cn',
|
||||||
actid: 'ea20211026151532',
|
actid: 'e202207181446311',
|
||||||
name: '崩坏3',
|
name: '崩坏3',
|
||||||
url: "https://bbs.mihoyo.com/bh3/",
|
url: "https://bbs.mihoyo.com/bh3/",
|
||||||
getReferer() {
|
getReferer() {
|
||||||
@ -82,30 +82,31 @@ export default class MihoYoApi {
|
|||||||
constructor(e) {
|
constructor(e) {
|
||||||
if (e) {
|
if (e) {
|
||||||
this.e = e
|
this.e = e
|
||||||
this.cookie=e.cookie
|
this.cookie = e.cookie
|
||||||
this.userId = String(e.user_id)
|
this.userId = String(e.user_id)
|
||||||
this.msgName = e.msg.replace(/#|签到|井|米游社|mys|社区/g, "")
|
this.msgName = e.msg.replace(/#|签到|井|米游社|mys|社区/g, "")
|
||||||
}
|
|
||||||
Data.createDir("", YamlDataUrl, false);
|
|
||||||
// //初始化配置文件
|
// //初始化配置文件
|
||||||
let data = this.getStoken(this.e.user_id);
|
let data = this.getStoken(this.e.user_id);
|
||||||
if(data){
|
if (data) {
|
||||||
this.cookies = `stuid=${data.stuid};stoken=${data.stoken};ltoken=${data.ltoken};`;
|
this.cookies = `stuid=${data.stuid};stoken=${data.stoken};ltoken=${data.ltoken};`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getbody() {
|
Data.createDir("", YamlDataUrl, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
getbody(name) {
|
||||||
for (let item in boards) {
|
for (let item in boards) {
|
||||||
if (boards[item].name === this.msgName) {
|
if (boards[item].name === name) {
|
||||||
return boards[item]
|
return boards[item]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async honkai3rdSignTask(name) {
|
async honkai3rdSignTask(name) {
|
||||||
let kkbody = this.getbody();
|
let kkbody = this.getbody(name);
|
||||||
try {
|
try {
|
||||||
// 获取账号信息
|
// 获取账号信息
|
||||||
const objData= await this.getUserInfo(kkbody)
|
const objData = await this.getUserInfo(kkbody)
|
||||||
if(objData.retcode!=200) {
|
if (objData.retcode != 200) {
|
||||||
return objData
|
return objData
|
||||||
}
|
}
|
||||||
if (!objData.nickname) {
|
if (!objData.nickname) {
|
||||||
@ -332,7 +333,7 @@ export default class MihoYoApi {
|
|||||||
.getpubHeaders(board)).timeout(10000);
|
.getpubHeaders(board)).timeout(10000);
|
||||||
let resObj = JSON.parse(res.text);
|
let resObj = JSON.parse(res.text);
|
||||||
let data = resObj.data
|
let data = resObj.data
|
||||||
if(resObj.retcode!=0){
|
if (resObj.retcode != 0) {
|
||||||
return resObj
|
return resObj
|
||||||
}
|
}
|
||||||
const game_uid = data?.list?. [0]?.game_uid
|
const game_uid = data?.list?. [0]?.game_uid
|
||||||
@ -341,25 +342,25 @@ export default class MihoYoApi {
|
|||||||
return {
|
return {
|
||||||
game_uid,
|
game_uid,
|
||||||
region,
|
region,
|
||||||
nickname,retcode:200
|
nickname,
|
||||||
|
retcode: 200
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 游戏签到操作
|
// 游戏签到操作
|
||||||
async postSign(board, game_uid, region) {
|
async postSign(board, game_uid, region) {
|
||||||
let web_api=`https://api-takumi.mihoyo.com`
|
let web_api = `https://api-takumi.mihoyo.com`
|
||||||
let url =
|
let url =
|
||||||
`${web_api}/common/eutheniav2/sign`
|
`${web_api}/event/luna/sign`
|
||||||
if(board.name=="原神"){
|
if (board.name == "原神") {
|
||||||
url=`${web_api}/event/bbs_sign_reward/sign`
|
url = `${web_api}/event/bbs_sign_reward/sign`
|
||||||
}
|
}
|
||||||
if(board.name=="崩坏2"||board.name=="未定事件簿"){
|
if (board.name == "崩坏2" || board.name == "未定事件簿") {
|
||||||
url=`${web_api}/event/luna/info?lang=zh-cn`
|
url = `${web_api}/event/luna/info?lang=zh-cn`
|
||||||
}
|
}
|
||||||
url+=`?region=${region}&act_id=${board.actid}&uid=${game_uid}`
|
url += `?region=${region}&act_id=${board.actid}&uid=${game_uid}`
|
||||||
// if(board.name==="崩坏3"){
|
// if (board.name === "崩坏3") {
|
||||||
// url=`https://webstatic.mihoyo.com/bh3/event/signin-cn/index.html?bbs_presentation_style=fullscreen&bbs_game_role_required=bh3_cn&bbs_auth_required=true&act_id=${board.actid}&utm_source=bbs&utm_medium=mys&utm_campaign=icon`
|
// url = `${web_api}/event/luna/info?lang=zh-cn®ion=${region}&act_id=${board.actid}&uid=${game_uid}`
|
||||||
// }
|
// }
|
||||||
// console.log(url)
|
|
||||||
// console.log(this.e)
|
// console.log(this.e)
|
||||||
let res = await superagent.post(url).set(this.getpubHeaders(board)).timeout(10000);
|
let res = await superagent.post(url).set(this.getpubHeaders(board)).timeout(10000);
|
||||||
let resObj = JSON.parse(res.text);
|
let resObj = JSON.parse(res.text);
|
||||||
|
@ -21,9 +21,23 @@ export function randomString(length){
|
|||||||
}
|
}
|
||||||
return randomStr;
|
return randomStr;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 发送私聊消息,仅给好友发送
|
||||||
|
* @param user_id qq号
|
||||||
|
* @param msg 消息
|
||||||
|
*/
|
||||||
|
export async function relpyPrivate (userId, msg) {
|
||||||
|
userId = Number(userId)
|
||||||
|
let friend = Bot.fl.get(userId)
|
||||||
|
if (friend) {
|
||||||
|
logger.mark(`发送好友消息[${friend.nickname}](${userId})`)
|
||||||
|
return await Bot.pickUser(userId).sendMsg(msg).catch((err) => {
|
||||||
|
logger.mark(err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
export default {
|
export default {
|
||||||
sleepAsync,
|
sleepAsync,
|
||||||
randomSleepAsync,
|
randomSleepAsync,
|
||||||
randomString
|
randomString,relpyPrivate
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user