2022-11-10 23:38:34 +08:00
|
|
|
|
import YAML from 'yaml'
|
2022-10-12 16:51:51 +08:00
|
|
|
|
import miHoYoApi from "../model/mys/mihoyoApi.js"
|
2022-08-16 23:24:54 +08:00
|
|
|
|
import fs from 'node:fs'
|
|
|
|
|
import lodash from 'lodash'
|
2022-08-17 08:06:58 +08:00
|
|
|
|
import utils from '../model/mys/utils.js';
|
2022-08-16 23:24:54 +08:00
|
|
|
|
import gsCfg from './gsCfg.js';
|
|
|
|
|
import {
|
|
|
|
|
isV3
|
|
|
|
|
} from '../components/Changelog.js';
|
2022-10-12 16:51:51 +08:00
|
|
|
|
import {
|
|
|
|
|
Cfg,
|
|
|
|
|
Data
|
|
|
|
|
} from "../components/index.js";
|
|
|
|
|
import moment from 'moment'
|
2022-08-16 23:24:54 +08:00
|
|
|
|
const _path = process.cwd();
|
|
|
|
|
const plugin = "xiaoyao-cvs-plugin"
|
2022-08-18 23:15:49 +08:00
|
|
|
|
const nameData = ["原神", "崩坏3", "崩坏2", "未定事件簿"];
|
2022-10-12 16:51:51 +08:00
|
|
|
|
const yamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`;
|
|
|
|
|
const cloudDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yunToken/`
|
|
|
|
|
let bbsTask = false;
|
|
|
|
|
let cloudTask = false;
|
|
|
|
|
let mysTask = false;
|
2022-08-16 23:24:54 +08:00
|
|
|
|
/** 配置文件 */
|
|
|
|
|
export default class user {
|
|
|
|
|
constructor(e) {
|
2022-08-18 23:15:49 +08:00
|
|
|
|
this.e = e;
|
|
|
|
|
this.stokenPath = `./plugins/${plugin}/data/yaml/`
|
|
|
|
|
this.yunPath = `./plugins/${plugin}/data/yunToken/`;
|
2022-10-13 11:03:19 +08:00
|
|
|
|
Data.createDir("", this.yunPath, false)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
this.ForumData = Data.readJSON(`${_path}/plugins/xiaoyao-cvs-plugin/defSet/json`, "mys")
|
|
|
|
|
this.configSign = gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config");
|
|
|
|
|
this.configSign.signlist = this.configSign.signlist || "原神|崩坏3|崩坏2|未定事件簿".split("|")
|
2023-01-15 19:09:26 +08:00
|
|
|
|
this.getToken = this.configSign.getToken || ''
|
2022-08-16 23:24:54 +08:00
|
|
|
|
this.getyunToken(this.e)
|
|
|
|
|
}
|
2023-01-15 19:09:26 +08:00
|
|
|
|
|
2022-08-18 23:15:49 +08:00
|
|
|
|
async getCkData() {
|
|
|
|
|
let sumData = {};
|
2022-10-12 16:51:51 +08:00
|
|
|
|
let yunres = await this.cloudSeach();
|
|
|
|
|
let yundata = yunres.data
|
|
|
|
|
if (yunres.retcode === 0) {
|
|
|
|
|
sumData["云原神"] = {
|
2022-10-13 10:47:13 +08:00
|
|
|
|
"今日可获取": yundata?.coin?.free_coin_num,
|
2022-10-13 11:03:19 +08:00
|
|
|
|
"米云币": yundata?.coin?.coin_num,
|
2022-10-12 16:51:51 +08:00
|
|
|
|
"免费时长": yundata?.free_time?.free_time,
|
|
|
|
|
"总时长": yundata.total_time
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let mysres = await this.bbsSeachSign();
|
|
|
|
|
if (mysres.retcode === 0) {
|
|
|
|
|
sumData["米游社"] = {
|
|
|
|
|
"米游币任务": mysres.data.can_get_points != 0 ? "未完成" : "已完成",
|
|
|
|
|
"米游币余额": mysres.data.total_points,
|
|
|
|
|
"今日剩余可获取": mysres.data.can_get_points
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let resSign = await this.multiSign(this.ForumData);
|
|
|
|
|
if (resSign?.upData) {
|
|
|
|
|
for (let item of resSign?.upData) {
|
|
|
|
|
let num = lodash.random(0, 9999);
|
|
|
|
|
item.upName = item.upName == "原神" ? "ys" : item.upName == "崩坏3" ? "bh3" : item.upName ==
|
|
|
|
|
"崩坏2" ? "bh2" : item.upName == "未定事件簿" ? "wdy" : ""
|
|
|
|
|
sumData[item.upName + "" + num] = {
|
|
|
|
|
"uid": item.game_uid,
|
|
|
|
|
"游戏昵称": item.nickname,
|
|
|
|
|
"等级": item.level,
|
|
|
|
|
"今日签到": item.is_sign ? "已签到" : "未签到",
|
|
|
|
|
"累计签到": item.total_sign_day + "天",
|
|
|
|
|
"今天奖励": item.awards
|
2022-08-16 23:44:24 +08:00
|
|
|
|
}
|
2022-08-16 23:24:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
return sumData;
|
|
|
|
|
}
|
2022-10-14 10:02:45 +08:00
|
|
|
|
async getData(type, data = {}, isck = true) {
|
|
|
|
|
if (isck) {
|
2022-10-13 16:19:09 +08:00
|
|
|
|
await this.cookie(this.e)
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
this.miHoYoApi = new miHoYoApi(this.e);
|
|
|
|
|
let res = await this.miHoYoApi.getData(type, data)
|
|
|
|
|
return res
|
|
|
|
|
}
|
2022-11-10 23:38:34 +08:00
|
|
|
|
|
|
|
|
|
async multiSign(forumData, isCk = false) {
|
2022-10-12 16:51:51 +08:00
|
|
|
|
let upData = [],
|
|
|
|
|
message = '';
|
2022-11-10 23:38:34 +08:00
|
|
|
|
if (isCk) {
|
2022-11-08 00:17:37 +08:00
|
|
|
|
await this.cookie(this.e)
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
for (let forum of forumData) {
|
|
|
|
|
if (!(this.configSign.signlist.includes(forum.name))) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
let res
|
|
|
|
|
try {
|
2022-10-13 10:47:13 +08:00
|
|
|
|
message += `**${forum.name}**\n`
|
2022-10-31 22:23:11 +08:00
|
|
|
|
res = await this.getData("userGameInfo", forum, false)
|
2022-10-14 13:27:16 +08:00
|
|
|
|
await utils.sleepAsync(3000) //等几毫秒免得请求太频繁了
|
2022-11-10 23:38:34 +08:00
|
|
|
|
if (res.retcode === -100) {
|
|
|
|
|
message = `用户:${this.e.user_id}:cookie失效`
|
|
|
|
|
return {
|
|
|
|
|
message,
|
|
|
|
|
upData
|
|
|
|
|
};
|
2022-11-06 22:31:47 +08:00
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (res?.data?.list?.length === 0 || !res?.data?.list) {
|
|
|
|
|
message += `签到: 未绑定${forum.name}信息\n`;
|
2022-10-31 22:23:11 +08:00
|
|
|
|
if (this.allSign) {
|
2022-10-16 12:29:31 +08:00
|
|
|
|
this.allSign[forum.name].bindGame++;
|
|
|
|
|
}
|
2022-10-17 04:56:55 +08:00
|
|
|
|
await utils.randomSleepAsync()
|
2022-10-12 16:51:51 +08:00
|
|
|
|
continue;
|
2022-08-16 23:44:24 +08:00
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
message += `${forum.name}共计${res?.data?.list.length}个账号\n`;
|
2022-10-31 22:23:11 +08:00
|
|
|
|
|
2022-10-12 16:51:51 +08:00
|
|
|
|
for (let item of res?.data?.list) {
|
|
|
|
|
let data = Object.assign({}, forum, item)
|
|
|
|
|
item.is_sign = true;
|
|
|
|
|
item.upName = forum.name
|
2022-10-31 22:23:11 +08:00
|
|
|
|
res = await this.getData("isSign", data, false)
|
2022-10-14 13:27:16 +08:00
|
|
|
|
await utils.sleepAsync(500)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
item.total_sign_day = res?.data?.total_sign_day
|
|
|
|
|
if (res?.data?.is_sign) {
|
2022-10-31 22:23:11 +08:00
|
|
|
|
if (this.allSign) {
|
2022-10-16 12:29:31 +08:00
|
|
|
|
this.allSign[forum.name].isSign++;
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
message += `${item.nickname}-${item.game_uid}:今日已签到~\n`;
|
|
|
|
|
} else {
|
2023-01-15 19:09:26 +08:00
|
|
|
|
let signMsg = '';
|
2023-01-04 20:15:15 +08:00
|
|
|
|
for (let i = 0; i < 2; i++) { //循环请求
|
|
|
|
|
await utils.sleepAsync(2000)
|
|
|
|
|
res = await this.getData("sign", data, false)
|
|
|
|
|
if (res?.data?.gt) {
|
2023-01-15 19:09:26 +08:00
|
|
|
|
let validate = await this.geetest(res.data)
|
2023-01-04 20:15:15 +08:00
|
|
|
|
if (validate) {
|
|
|
|
|
let header = {}
|
|
|
|
|
header["x-rpc-challenge"] = res["data"]["challenge"]
|
|
|
|
|
header["x-rpc-validate"] = validate
|
|
|
|
|
header["x-rpc-seccode"] = `${validate}|jordan`
|
|
|
|
|
data.headers = header
|
|
|
|
|
res = await this.getData("sign", data, false)
|
|
|
|
|
if (!res?.data?.gt) {
|
2023-03-09 23:45:55 +08:00
|
|
|
|
if (this.allSign) {
|
2023-01-04 20:15:15 +08:00
|
|
|
|
this.allSign[forum.name].sign++;
|
|
|
|
|
}
|
|
|
|
|
signMsg = `${item.nickname}-${item.game_uid}:验证码签到成功~\n`
|
2023-02-19 21:29:01 +08:00
|
|
|
|
item.total_sign_day++;
|
2023-01-04 20:15:15 +08:00
|
|
|
|
break;
|
|
|
|
|
} else {
|
2023-03-09 23:45:55 +08:00
|
|
|
|
if (this.allSign) {
|
2023-01-04 20:15:15 +08:00
|
|
|
|
this.allSign[forum.name].error++;
|
|
|
|
|
}
|
|
|
|
|
item.is_sign = false;
|
|
|
|
|
signMsg =
|
|
|
|
|
`${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到\n`;
|
2022-10-31 22:23:11 +08:00
|
|
|
|
}
|
2022-10-14 10:02:45 +08:00
|
|
|
|
} else {
|
2023-03-09 23:45:55 +08:00
|
|
|
|
if (this.allSign ) {
|
2022-10-31 22:23:11 +08:00
|
|
|
|
this.allSign[forum.name].error++;
|
2022-10-14 10:02:45 +08:00
|
|
|
|
}
|
2023-01-04 20:15:15 +08:00
|
|
|
|
signMsg = `${item.nickname}-${item.game_uid}:验证码失败~\n`
|
2022-10-14 10:02:45 +08:00
|
|
|
|
}
|
2023-01-15 19:09:26 +08:00
|
|
|
|
|
2022-10-14 10:02:45 +08:00
|
|
|
|
} else {
|
2022-10-31 22:23:11 +08:00
|
|
|
|
if (this.allSign) {
|
2023-01-04 20:15:15 +08:00
|
|
|
|
this.allSign[forum.name].sign++;
|
2022-10-16 12:29:31 +08:00
|
|
|
|
}
|
2023-01-04 20:15:15 +08:00
|
|
|
|
item.total_sign_day++;
|
|
|
|
|
signMsg =
|
|
|
|
|
`${item.nickname}-${item.game_uid}:${res.message == "OK" ? "签到成功" : res.message}\n`
|
|
|
|
|
break;
|
2022-10-31 22:23:11 +08:00
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
}
|
2023-01-15 19:09:26 +08:00
|
|
|
|
message += signMsg
|
2022-10-12 16:51:51 +08:00
|
|
|
|
}
|
|
|
|
|
//获取签到信息和奖励信息
|
2022-10-31 22:23:11 +08:00
|
|
|
|
const SignInfo = await this.getData("home", data, false)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (SignInfo) {
|
|
|
|
|
let awards = SignInfo.data.awards[item.total_sign_day - 1];
|
|
|
|
|
item.awards = awards?.name + "*" + awards?.cnt
|
|
|
|
|
}
|
|
|
|
|
upData.push(item)
|
2022-10-14 05:33:05 +08:00
|
|
|
|
await utils.randomSleepAsync()
|
2022-10-12 16:51:51 +08:00
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
2022-10-31 22:23:11 +08:00
|
|
|
|
if (this.allSign) {
|
2022-10-16 12:29:31 +08:00
|
|
|
|
this.allSign[forum.name].error++;
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
Bot.logger.error(`${forum.name} 签到失败 [${res?.message}]`);
|
|
|
|
|
message += `签到失败: [${res?.message}]\n`;
|
2022-08-16 23:44:24 +08:00
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
message,
|
|
|
|
|
upData
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
async docHelp(type) {
|
2022-10-31 13:57:07 +08:00
|
|
|
|
return this.configSign[type.includes("云") ? "cloudDoc" : "cookiesDoc"]
|
2022-10-12 16:51:51 +08:00
|
|
|
|
}
|
2022-10-13 11:03:19 +08:00
|
|
|
|
async cloudSign() {
|
2023-01-15 19:09:26 +08:00
|
|
|
|
await this.cloudSeach()
|
2022-10-13 10:47:13 +08:00
|
|
|
|
let res = await this.getData("cloudReward")
|
2023-03-26 20:12:43 +08:00
|
|
|
|
Bot.logger.mark(`\n云原神签到用户:${this.e.user_id}:[接口返回]${res.message}\n`)
|
2022-10-13 11:03:19 +08:00
|
|
|
|
if (res?.data?.list?.length == 0 || !res?.data?.list) {
|
|
|
|
|
res.message = `您今天的奖励已经领取了~`
|
|
|
|
|
} else {
|
|
|
|
|
let sendMsg = ``
|
|
|
|
|
for (let item of res?.data?.list) {
|
2022-10-13 10:47:13 +08:00
|
|
|
|
let reward_id = item.id;
|
|
|
|
|
let reward_msg = item.msg;
|
2022-10-13 11:03:19 +08:00
|
|
|
|
res = await this.getData("cloudGamer", {
|
|
|
|
|
reward_id
|
|
|
|
|
})
|
2023-02-19 21:29:01 +08:00
|
|
|
|
// let row=JSON.parse(reward_msg);
|
2022-10-13 11:03:19 +08:00
|
|
|
|
sendMsg += `\n领取奖励,ID:${reward_id},Msg:${reward_msg}`
|
2022-10-13 10:47:13 +08:00
|
|
|
|
}
|
2022-10-13 11:03:19 +08:00
|
|
|
|
res.message = sendMsg;
|
2022-10-13 10:47:13 +08:00
|
|
|
|
}
|
2022-10-13 11:35:24 +08:00
|
|
|
|
Bot.logger.mark(`\n云原神签到用户:${this.e.user_id}:${res.message}\n`)
|
2022-10-13 10:47:13 +08:00
|
|
|
|
return res
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
async cloudSeach() {
|
2022-12-08 15:44:13 +08:00
|
|
|
|
let res = await this.getData("cloudGet")
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (res?.retcode == -100) {
|
|
|
|
|
res.message = "云原神token失效/防沉迷"
|
|
|
|
|
res.isOk = false;
|
2023-01-04 20:15:15 +08:00
|
|
|
|
} else {
|
2022-10-12 16:51:51 +08:00
|
|
|
|
res.isOk = true;
|
2022-12-08 15:44:13 +08:00
|
|
|
|
if (res?.data?.total_time) {
|
|
|
|
|
res.message =
|
|
|
|
|
`米云币:${res?.data?.coin?.coin_num},免费时长:${res?.data?.free_time?.free_time}分钟,总时长:${res?.data?.total_time}分钟`;
|
|
|
|
|
}
|
2022-08-16 23:44:24 +08:00
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
async bbsSeachSign() {
|
|
|
|
|
let res = await this.getData("bbsisSign", {
|
|
|
|
|
name: "原神"
|
|
|
|
|
})
|
|
|
|
|
if (!res?.data) {
|
|
|
|
|
res.message = `登录Stoken失效请重新获取cookies或stoken保存~`;
|
|
|
|
|
res.isOk = false;
|
|
|
|
|
this.delSytk(yamlDataUrl, this.e)
|
|
|
|
|
} else {
|
|
|
|
|
res.message = `当前米游币数量为:${res.data.total_points},今日剩余可获取:${res.data.can_get_points}`
|
|
|
|
|
res.isOk = true;
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
async getbbsSign(forumData) {
|
|
|
|
|
let message = '',
|
2022-10-12 21:16:44 +08:00
|
|
|
|
challenge = '',
|
2022-10-12 16:51:51 +08:00
|
|
|
|
res;
|
|
|
|
|
try {
|
2022-10-14 10:02:45 +08:00
|
|
|
|
res = await this.bbsSeachSign()
|
|
|
|
|
if (res?.data?.can_get_points == 0) {
|
2022-10-13 11:35:24 +08:00
|
|
|
|
return {
|
2022-10-14 10:02:45 +08:00
|
|
|
|
message: `签到任务已完成,无需重复签到`
|
2022-10-13 11:35:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
for (let forum of forumData) {
|
|
|
|
|
let trueDetail = 0;
|
|
|
|
|
let Vote = 0;
|
|
|
|
|
let Share = 0;
|
|
|
|
|
let sumcount = 0;
|
|
|
|
|
message += `\n**${forum.name}**\n`
|
2022-10-31 22:23:11 +08:00
|
|
|
|
res = await this.getData("bbsSign", forum, false)
|
2022-11-24 23:12:36 +08:00
|
|
|
|
if (res?.retcode == -100) {
|
|
|
|
|
return {
|
|
|
|
|
message: '登录失效'
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (res?.retcode == 1034) {
|
2022-10-12 21:16:44 +08:00
|
|
|
|
challenge = await this.bbsGeetest()
|
|
|
|
|
if (challenge) {
|
|
|
|
|
forum["headers"] = {
|
|
|
|
|
"x-rpc-challenge": challenge
|
|
|
|
|
}
|
2022-11-24 23:12:36 +08:00
|
|
|
|
res = await this.getData("bbsSign", forum, false)
|
|
|
|
|
if (res?.retcode == 1034) {
|
|
|
|
|
message += `社区签到: 验证码失败\n`;
|
|
|
|
|
} else {
|
|
|
|
|
message += `社区签到: 验证码成功\n`;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
message += `社区签到: 验证码失败\n`;
|
2022-10-12 21:16:44 +08:00
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
} else {
|
|
|
|
|
message += `社区签到: ${res.message}\n`;
|
|
|
|
|
}
|
|
|
|
|
Bot.logger.mark(`${this.e.user_id}:${this.e.uid}:${forum.name} 社区签到结果: [${res.message}]`);
|
2022-10-31 22:23:11 +08:00
|
|
|
|
res = await this.getData("bbsPostList", forum, false)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
sumcount++;
|
|
|
|
|
let postList = res.data.list;
|
|
|
|
|
let postId
|
|
|
|
|
for (let post of postList) {
|
|
|
|
|
post = post.post;
|
|
|
|
|
postId = post['post_id']
|
|
|
|
|
res = await this.getData("bbsPostFull", {
|
|
|
|
|
postId
|
2022-10-31 22:23:11 +08:00
|
|
|
|
}, false)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (res?.message && res?.retcode == 0) {
|
|
|
|
|
trueDetail++;
|
|
|
|
|
}
|
2022-10-12 21:16:44 +08:00
|
|
|
|
if (res?.retcode == 1034) {
|
|
|
|
|
challenge = await this.bbsGeetest()
|
|
|
|
|
if (challenge) {
|
2022-10-13 11:03:19 +08:00
|
|
|
|
let data = {
|
|
|
|
|
postId,
|
|
|
|
|
headers: {
|
|
|
|
|
"x-rpc-challenge": challenge,
|
|
|
|
|
}
|
2022-10-12 21:16:44 +08:00
|
|
|
|
}
|
2022-10-31 22:23:11 +08:00
|
|
|
|
await this.getData("bbsPostFull", data, false)
|
2022-10-12 21:16:44 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
res = await this.getData("bbsVotePost", {
|
|
|
|
|
postId
|
2022-10-31 22:23:11 +08:00
|
|
|
|
}, false)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (res?.message && res?.retcode == 0) {
|
|
|
|
|
Vote++;
|
2022-08-16 23:24:54 +08:00
|
|
|
|
}
|
2022-10-12 21:16:44 +08:00
|
|
|
|
if (res?.retcode == 1034) {
|
|
|
|
|
challenge = await this.bbsGeetest()
|
|
|
|
|
if (challenge) {
|
2022-10-13 11:03:19 +08:00
|
|
|
|
let data = {
|
|
|
|
|
postId,
|
|
|
|
|
headers: {
|
|
|
|
|
"x-rpc-challenge": challenge,
|
|
|
|
|
}
|
2022-10-12 21:16:44 +08:00
|
|
|
|
}
|
2022-10-31 22:23:11 +08:00
|
|
|
|
await this.getData("bbsVotePost", data, false)
|
2022-10-12 21:16:44 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
await utils.randomSleepAsync(2);
|
|
|
|
|
}
|
|
|
|
|
res = await this.getData("bbsShareConf", {
|
|
|
|
|
postId
|
2022-10-31 22:23:11 +08:00
|
|
|
|
}, false)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (res?.message && res?.retcode == 0) {
|
|
|
|
|
Share++;
|
2022-08-16 23:24:54 +08:00
|
|
|
|
}
|
2023-03-10 00:32:12 +08:00
|
|
|
|
message += `共读取帖子记录${20 * sumcount}\n浏览:${trueDetail} 点赞:${Vote} 分享:${Share}\n`;
|
2022-10-13 11:03:19 +08:00
|
|
|
|
Bot.logger.mark(`\n用户${this.e.user_id}:\n${message}`)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
await utils.randomSleepAsync(3);
|
2022-08-16 23:24:54 +08:00
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
} catch (ex) {
|
|
|
|
|
Bot.logger.error(`出问题了:${ex}`);
|
|
|
|
|
message += `${this.e.user_id}获取米游币异常`;
|
2022-08-16 23:24:54 +08:00
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
return {
|
|
|
|
|
message
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
async signTask(e = "") {
|
|
|
|
|
let mul = e;
|
|
|
|
|
//暂不支持多个uid签到
|
|
|
|
|
Bot.logger.mark(`开始米社签到任务`);
|
|
|
|
|
let isAllSign = this.configSign.isAllSign
|
|
|
|
|
let userIdList = [];
|
|
|
|
|
let dir = './data/MysCookie/'
|
|
|
|
|
if (isV3) {
|
2022-11-06 22:31:47 +08:00
|
|
|
|
userIdList = (await gsCfg.getBingAllCk()).ckQQ
|
2022-10-12 16:51:51 +08:00
|
|
|
|
} else {
|
2022-11-10 23:38:34 +08:00
|
|
|
|
userIdList = NoteCookie;
|
2022-10-12 16:51:51 +08:00
|
|
|
|
}
|
|
|
|
|
if (mysTask) {
|
|
|
|
|
e.reply(`米社自动签到任务进行中,请勿重复触发指令`)
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
mysTask = true;
|
2022-11-10 23:38:34 +08:00
|
|
|
|
let userIdkeys = Object.keys(userIdList);
|
2022-10-12 16:51:51 +08:00
|
|
|
|
let tips = ['开始米社签到任务']
|
2022-11-06 22:31:47 +08:00
|
|
|
|
let time = userIdkeys.length * 25 + 5 + (userIdkeys.length / 3 * 60)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
let finishTime = moment().add(time, 's').format('MM-DD HH:mm:ss')
|
2022-11-06 22:31:47 +08:00
|
|
|
|
tips.push(`\n签到用户:${userIdkeys.length}个`)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
tips.push(`\n预计需要:${this.countTime(time)}`)
|
|
|
|
|
if (time > 120) {
|
|
|
|
|
tips.push(`\n完成时间:${finishTime}`)
|
|
|
|
|
}
|
2022-11-06 22:31:47 +08:00
|
|
|
|
Bot.logger.mark(`签到用户:${userIdkeys.length}个,预计需要${this.countTime(time)} ${finishTime} 完成`)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (mul) {
|
|
|
|
|
await this.e.reply(tips)
|
|
|
|
|
if (this.e.msg.includes('force')) this.force = true
|
|
|
|
|
} else {
|
|
|
|
|
await utils.relpyPrivate(await gsCfg.getMasterQQ(), tips)
|
|
|
|
|
await utils.sleepAsync(lodash.random(1, 20) * 1000)
|
|
|
|
|
}
|
|
|
|
|
let _reply = e.reply
|
|
|
|
|
let msg = e?.msg;
|
2022-10-31 22:23:11 +08:00
|
|
|
|
this.allSign = {
|
|
|
|
|
findModel: ["崩坏3", "崩坏2", '原神', '未定事件簿'],
|
|
|
|
|
"崩坏3": {
|
|
|
|
|
bindGame: 0,
|
|
|
|
|
sign: 0,
|
|
|
|
|
isSign: 0,
|
|
|
|
|
error: 0,
|
2022-10-16 10:51:10 +08:00
|
|
|
|
},
|
2022-10-31 22:23:11 +08:00
|
|
|
|
"崩坏2": {
|
|
|
|
|
bindGame: 0,
|
|
|
|
|
sign: 0,
|
|
|
|
|
isSign: 0,
|
|
|
|
|
error: 0,
|
2022-10-16 10:51:10 +08:00
|
|
|
|
},
|
2022-10-31 22:23:11 +08:00
|
|
|
|
"原神": {
|
|
|
|
|
bindGame: 0,
|
|
|
|
|
sign: 0,
|
|
|
|
|
isSign: 0,
|
|
|
|
|
error: 0,
|
2022-10-16 10:51:10 +08:00
|
|
|
|
},
|
2022-10-31 22:23:11 +08:00
|
|
|
|
"未定事件簿": {
|
|
|
|
|
bindGame: 0,
|
|
|
|
|
sign: 0,
|
|
|
|
|
isSign: 0,
|
|
|
|
|
error: 0,
|
2022-10-16 10:51:10 +08:00
|
|
|
|
},
|
2022-10-31 22:23:11 +08:00
|
|
|
|
sendReply() {
|
|
|
|
|
let msg = ""
|
|
|
|
|
for (let item of this.findModel) {
|
|
|
|
|
msg +=
|
|
|
|
|
`**${item}**\n已签:${this[item].isSign}\n签到成功:${this[item].sign}\n未绑定信息:${this[item].bindGame}\n签到失败异常:${this[item].error}\n`
|
2022-10-16 10:51:10 +08:00
|
|
|
|
}
|
|
|
|
|
return msg
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-06 22:31:47 +08:00
|
|
|
|
for (let qq of userIdkeys) {
|
2022-10-12 16:51:51 +08:00
|
|
|
|
let user_id = qq;
|
|
|
|
|
let e = {
|
|
|
|
|
user_id,
|
|
|
|
|
qq,
|
2022-11-06 22:31:47 +08:00
|
|
|
|
isTask: true,
|
2022-11-10 23:38:34 +08:00
|
|
|
|
uid: userIdList[qq].uid,
|
|
|
|
|
cookie: userIdList[qq].cookie || userIdList[qq].ck,
|
2022-10-12 16:51:51 +08:00
|
|
|
|
};
|
|
|
|
|
if (msg) {
|
|
|
|
|
e.msg = msg.replace(/全部|签到|米社/g, "");
|
|
|
|
|
} else {
|
|
|
|
|
e.msg = "全部"
|
|
|
|
|
}
|
|
|
|
|
Bot.logger.mark(`正在为qq${user_id}米社签到中...`);
|
2022-10-31 22:23:11 +08:00
|
|
|
|
|
2022-10-17 04:56:55 +08:00
|
|
|
|
this.e = e;
|
|
|
|
|
let res = await this.multiSign(this.getDataList(e.msg));
|
|
|
|
|
Bot.logger.mark(`${res.message}`)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
e.reply = (msg) => {
|
2022-10-16 10:51:10 +08:00
|
|
|
|
if (!isAllSign || mul) {
|
2022-10-12 16:51:51 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (msg.includes("OK")) {
|
|
|
|
|
utils.relpyPrivate(qq, msg + "\n自动签到成功");
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-10-17 04:56:55 +08:00
|
|
|
|
e.reply(res.message)
|
2022-10-16 10:51:10 +08:00
|
|
|
|
this.e.reply(res.message)
|
|
|
|
|
await utils.sleepAsync(15000);
|
2022-10-12 16:51:51 +08:00
|
|
|
|
}
|
2022-10-31 22:23:11 +08:00
|
|
|
|
msg = `米社签到任务完成\n` + this.allSign.sendReply()
|
2022-10-12 16:51:51 +08:00
|
|
|
|
Bot.logger.mark(msg);
|
|
|
|
|
if (mul) {
|
|
|
|
|
_reply(msg)
|
|
|
|
|
} else {
|
|
|
|
|
await utils.relpyPrivate(await gsCfg.getMasterQQ(), msg)
|
|
|
|
|
}
|
|
|
|
|
mysTask = false;
|
|
|
|
|
}
|
|
|
|
|
async cloudTask(e = "") {
|
|
|
|
|
let mul = e;
|
|
|
|
|
Bot.logger.mark(`云原神签到任务开始`);
|
|
|
|
|
let files = fs.readdirSync(this.yunPath).filter(file => file.endsWith('.yaml'))
|
2023-03-26 20:12:43 +08:00
|
|
|
|
if(files.length==0) return;
|
2022-11-06 22:31:47 +08:00
|
|
|
|
let isCloudSignMsg = this.configSign.isCloudSignMsg
|
2022-10-12 16:51:51 +08:00
|
|
|
|
let userIdList = (files.join(",").replace(/.yaml/g, "").split(","))
|
|
|
|
|
if (cloudTask) {
|
|
|
|
|
e.reply(`云原神自动签到任务进行中,请勿重复触发指令`)
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
let tips = ['开始云原神签到任务']
|
|
|
|
|
let time = userIdList.length * 3.5 + 5
|
|
|
|
|
let finishTime = moment().add(time, 's').format('MM-DD HH:mm:ss')
|
|
|
|
|
tips.push(`\n签到用户:${userIdList.length}个`)
|
|
|
|
|
tips.push(`\n预计需要:${this.countTime(time)}`)
|
|
|
|
|
if (time > 120) {
|
|
|
|
|
tips.push(`\n完成时间:${finishTime}`)
|
|
|
|
|
}
|
2022-11-06 22:31:47 +08:00
|
|
|
|
Bot.logger.mark(`签到用户:${userIdList.length}个,预计需要${this.countTime(time)} ${finishTime} 完成`)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (mul) {
|
|
|
|
|
await this.e.reply(tips)
|
|
|
|
|
} else {
|
|
|
|
|
await utils.relpyPrivate(await gsCfg.getMasterQQ(), tips)
|
|
|
|
|
await utils.sleepAsync(lodash.random(1, 20) * 1000)
|
|
|
|
|
}
|
|
|
|
|
cloudTask = true;
|
|
|
|
|
let _reply = e.reply
|
|
|
|
|
for (let qq of userIdList) {
|
|
|
|
|
let user_id = qq;
|
|
|
|
|
let e = {
|
|
|
|
|
user_id,
|
|
|
|
|
qq,
|
|
|
|
|
isTask: true
|
|
|
|
|
};
|
|
|
|
|
Bot.logger.mark(`正在为qq${user_id}云原神签到中...`);
|
|
|
|
|
e.msg = "全部"
|
|
|
|
|
e.reply = (msg) => {
|
2022-11-06 22:31:47 +08:00
|
|
|
|
if (!isCloudSignMsg || mul) {
|
2022-10-12 16:51:51 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (msg.includes("领取奖励")) {
|
|
|
|
|
utils.relpyPrivate(qq, msg + "\n云原神自动签到成功");
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-10-31 22:23:11 +08:00
|
|
|
|
this.e = e
|
2023-03-26 20:12:43 +08:00
|
|
|
|
await this.getyunToken(e)
|
2022-10-31 22:23:11 +08:00
|
|
|
|
let res = await this.cloudSign();
|
2022-10-16 10:51:10 +08:00
|
|
|
|
this.e.reply(res.message)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
await utils.sleepAsync(10000);
|
|
|
|
|
}
|
|
|
|
|
let msg = `云原神签到任务完成`
|
|
|
|
|
Bot.logger.mark(msg);
|
|
|
|
|
if (mul) {
|
|
|
|
|
_reply(msg)
|
|
|
|
|
} else {
|
|
|
|
|
await utils.relpyPrivate(await gsCfg.getMasterQQ(), msg)
|
|
|
|
|
}
|
|
|
|
|
cloudTask = false;
|
|
|
|
|
}
|
|
|
|
|
countTime(time) {
|
|
|
|
|
let hour = Math.floor((time / 3600) % 24)
|
|
|
|
|
let min = Math.floor((time / 60) % 60)
|
|
|
|
|
let sec = Math.floor(time % 60)
|
|
|
|
|
let msg = ''
|
|
|
|
|
if (hour > 0) msg += `${hour}小时`
|
|
|
|
|
if (min > 0) msg += `${min}分钟`
|
|
|
|
|
if (sec > 0) msg += `${sec}秒`
|
|
|
|
|
return msg
|
|
|
|
|
}
|
|
|
|
|
async bbsTask(e = "") {
|
|
|
|
|
let mul = e;
|
|
|
|
|
Bot.logger.mark(`开始米社米币签到任务`);
|
|
|
|
|
let stoken = await gsCfg.getBingStoken();
|
|
|
|
|
let isPushSign = this.configSign.isPushSign
|
|
|
|
|
let userIdList = Object.keys(stoken)
|
|
|
|
|
if (bbsTask) {
|
2023-01-04 20:15:15 +08:00
|
|
|
|
e.reply(`米游币自动签到任务进行中,请勿重复触发指令`)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
let tips = ['开始米游币签到任务']
|
2022-10-15 08:24:00 +08:00
|
|
|
|
let time = userIdList.length * 100 + 5
|
2022-10-12 16:51:51 +08:00
|
|
|
|
let finishTime = moment().add(time, 's').format('MM-DD HH:mm:ss')
|
|
|
|
|
tips.push(`\n签到用户:${userIdList.length}个`)
|
|
|
|
|
tips.push(`\n预计需要:${this.countTime(time)}`)
|
|
|
|
|
if (time > 120) {
|
|
|
|
|
tips.push(`\n完成时间:${finishTime}`)
|
|
|
|
|
}
|
2022-11-06 22:31:47 +08:00
|
|
|
|
Bot.logger.mark(`签到用户:${userIdList.length}个,预计需要${this.countTime(time)} ${finishTime} 完成`)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (mul) {
|
|
|
|
|
await this.e.reply(tips)
|
|
|
|
|
if (this.e.msg.includes('force')) this.force = true
|
|
|
|
|
} else {
|
|
|
|
|
await utils.relpyPrivate(await gsCfg.getMasterQQ(), tips)
|
|
|
|
|
await utils.sleepAsync(lodash.random(1, 20) * 1000)
|
|
|
|
|
}
|
|
|
|
|
bbsTask = true;
|
|
|
|
|
let _reply = e.reply
|
2023-01-15 19:09:26 +08:00
|
|
|
|
let counts = 0;
|
2022-10-12 16:51:51 +08:00
|
|
|
|
//获取需要签到的用户
|
|
|
|
|
for (let dataUid of stoken) {
|
|
|
|
|
for (let uuId in dataUid) {
|
2023-01-04 20:15:15 +08:00
|
|
|
|
try {
|
|
|
|
|
if (uuId[0] * 1 > 5) {
|
|
|
|
|
continue;
|
2022-10-12 16:51:51 +08:00
|
|
|
|
}
|
2023-01-04 20:15:15 +08:00
|
|
|
|
let data = dataUid[uuId]
|
|
|
|
|
let user_id = data.userId * 1;
|
|
|
|
|
let e = {
|
|
|
|
|
user_id,
|
|
|
|
|
isTask: true
|
|
|
|
|
};
|
|
|
|
|
counts++;
|
|
|
|
|
e.cookie = `stuid=${data.stuid};stoken=${data.stoken};ltoken=${data.ltoken};`;
|
|
|
|
|
Bot.logger.mark(`[米游币签到][第${counts}个]正在为qq${user_id}:uid:${uuId}签到中...`);
|
|
|
|
|
e.msg = "全部"
|
|
|
|
|
e.reply = (msg) => {
|
|
|
|
|
//关闭签到消息推送
|
|
|
|
|
if (!isPushSign || mul) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (msg.includes("OK")) { //签到成功并且不是已签到的才推送
|
|
|
|
|
utils.relpyPrivate(user_id, msg + "uid:" + uuId + "\n自动签到成功");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
this.e = e;
|
|
|
|
|
//await 代表同步 你可以尝试去除await以进行优化速度
|
|
|
|
|
let res = await this.getbbsSign(this.ForumData);
|
|
|
|
|
e.reply(res.message)
|
|
|
|
|
await utils.sleepAsync(10000);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
logger.error(`米游币签到报错:` + error)
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-12 16:51:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let msg = `米社米币签到任务完成`
|
|
|
|
|
Bot.logger.mark(msg);
|
|
|
|
|
if (mul) {
|
|
|
|
|
_reply(msg)
|
|
|
|
|
} else {
|
|
|
|
|
await utils.relpyPrivate(await gsCfg.getMasterQQ(), msg)
|
|
|
|
|
}
|
|
|
|
|
bbsTask = false;
|
|
|
|
|
}
|
2022-10-12 21:16:44 +08:00
|
|
|
|
async bbsGeetest() {
|
2023-02-18 00:11:15 +08:00
|
|
|
|
if(!this.getToken) return ""
|
2023-01-04 20:15:15 +08:00
|
|
|
|
try {
|
|
|
|
|
let res = await this.getData('bbsGetCaptcha', false)
|
|
|
|
|
// let challenge = res.data["challenge"]
|
2023-01-15 19:09:26 +08:00
|
|
|
|
// await this.getData("geeType", res.data, false)
|
2023-02-18 00:11:15 +08:00
|
|
|
|
res.data.getToken = this.getToken
|
2023-01-04 20:15:15 +08:00
|
|
|
|
res = await this.getData("validate", res.data, false)
|
|
|
|
|
if (res?.data?.validate) {
|
|
|
|
|
res = await this.getData("bbsCaptchaVerify", res.data, false)
|
|
|
|
|
return res["data"]["challenge"]
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
//大概率是数据空导致报错这种情况很少见捏,所以你可以忽略不看
|
|
|
|
|
Bot.logger.error('[validate][接口请求]异常信息:' + error)
|
|
|
|
|
return ""
|
2022-10-12 21:16:44 +08:00
|
|
|
|
}
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
async geetest(data) {
|
2023-02-18 00:11:15 +08:00
|
|
|
|
if(!this.getToken) return ""
|
2023-01-04 20:15:15 +08:00
|
|
|
|
try {
|
2023-02-18 00:11:15 +08:00
|
|
|
|
data.getToken = this.getToken
|
2023-01-04 20:15:15 +08:00
|
|
|
|
let res = await this.getData("validate", data, false)
|
|
|
|
|
if (res?.data?.validate) {
|
|
|
|
|
let validate = res?.data?.validate
|
|
|
|
|
return validate
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
//大概率是数据空导致报错这种情况很少见捏,所以你可以忽略不看
|
|
|
|
|
Bot.logger.error('[validate][接口请求]异常信息:' + error)
|
|
|
|
|
return ""
|
2022-10-12 21:16:44 +08:00
|
|
|
|
}
|
|
|
|
|
return ""
|
2022-08-16 23:24:54 +08:00
|
|
|
|
}
|
|
|
|
|
getyunToken(e) {
|
|
|
|
|
let file = `${this.yunPath}${e.user_id}.yaml`
|
|
|
|
|
try {
|
|
|
|
|
let ck = fs.readFileSync(file, 'utf-8')
|
|
|
|
|
ck = YAML.parse(ck)
|
|
|
|
|
this.e.devId = ck.devId;
|
|
|
|
|
this.e.yuntoken = ck.yuntoken;
|
|
|
|
|
return ck
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
async cookie(e) {
|
|
|
|
|
let {
|
|
|
|
|
cookie,
|
2022-08-18 23:15:49 +08:00
|
|
|
|
uid,
|
|
|
|
|
skuid
|
2022-08-16 23:24:54 +08:00
|
|
|
|
} = await this.getCookie(e);
|
|
|
|
|
let cookiesDoc = await this.getcookiesDoc();
|
|
|
|
|
if (!cookie) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-09-05 11:49:06 +08:00
|
|
|
|
let stokens = this.getStoken(e.user_id)
|
2022-08-18 23:15:49 +08:00
|
|
|
|
if (!stokens) {
|
2022-08-16 23:24:54 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-10-13 11:03:19 +08:00
|
|
|
|
let flot = await this.stoken(cookie, e)
|
2022-08-16 23:24:54 +08:00
|
|
|
|
await utils.sleepAsync(1000); //延迟加载防止文件未生成
|
|
|
|
|
if (!flot) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-08-18 23:15:49 +08:00
|
|
|
|
async getcookiesDoc() {
|
2022-08-16 23:24:54 +08:00
|
|
|
|
return await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").cookiesDoc
|
|
|
|
|
}
|
|
|
|
|
async getCookie(e) {
|
|
|
|
|
let skuid, cookie, uid
|
|
|
|
|
if (isV3) {
|
|
|
|
|
skuid = await gsCfg.getBingCookie(e.user_id);
|
2022-09-12 21:29:33 +08:00
|
|
|
|
cookie = skuid?.ck;
|
|
|
|
|
uid = skuid?.item;
|
2022-08-16 23:24:54 +08:00
|
|
|
|
} 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];
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-08 15:44:13 +08:00
|
|
|
|
if (!uid) {
|
|
|
|
|
uid = e.runtime?.user?._regUid
|
|
|
|
|
}
|
2022-08-16 23:24:54 +08:00
|
|
|
|
this.e.uid = uid;
|
|
|
|
|
this.e.cookie = cookie;
|
|
|
|
|
return {
|
|
|
|
|
cookie,
|
|
|
|
|
uid,
|
|
|
|
|
skuid
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
async stoken(cookie, e) {
|
|
|
|
|
this.e = e;
|
|
|
|
|
let datalist = this.getStoken(e.user_id) || {}
|
|
|
|
|
if (Object.keys(datalist).length > 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-10-13 11:03:19 +08:00
|
|
|
|
const map = await utils.getCookieMap(cookie);
|
2022-10-13 10:47:13 +08:00
|
|
|
|
let loginTicket = map?.get("login_ticket");
|
|
|
|
|
const loginUid = map?.get("login_uid") ? map?.get("login_uid") : map?.get("ltuid");
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (isV3) {
|
|
|
|
|
loginTicket = gsCfg.getBingCookie(e.user_id).login_ticket
|
|
|
|
|
}
|
2022-10-13 11:03:19 +08:00
|
|
|
|
let mhyapi = new miHoYoApi(this.e);
|
2022-10-13 10:47:13 +08:00
|
|
|
|
let res = await mhyapi.getData("bbsStoken", {
|
2022-10-12 16:51:51 +08:00
|
|
|
|
loginUid,
|
|
|
|
|
loginTicket
|
2022-10-31 22:23:11 +08:00
|
|
|
|
}, false)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (res?.data) {
|
|
|
|
|
datalist[e.uid] = {
|
2022-10-13 10:47:13 +08:00
|
|
|
|
stuid: map?.get("account_id"),
|
2022-10-14 21:43:10 +08:00
|
|
|
|
stoken: res.data.list[0].token,
|
|
|
|
|
ltoken: res.data.list[1].token,
|
2022-10-12 16:51:51 +08:00
|
|
|
|
uid: e.uid,
|
|
|
|
|
userId: e.user_id,
|
|
|
|
|
is_sign: true
|
|
|
|
|
}
|
|
|
|
|
gsCfg.saveBingStoken(e.user_id, datalist)
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-09-05 11:49:06 +08:00
|
|
|
|
getStoken(userId) {
|
2022-10-12 16:51:51 +08:00
|
|
|
|
let file = `${yamlDataUrl}/${userId}.yaml`
|
2022-09-05 11:49:06 +08:00
|
|
|
|
try {
|
|
|
|
|
let ck = fs.readFileSync(file, 'utf-8')
|
|
|
|
|
ck = YAML.parse(ck)
|
|
|
|
|
if (ck?.uid) {
|
|
|
|
|
let datalist = {};
|
|
|
|
|
ck.userId = this.e.user_id
|
|
|
|
|
datalist[ck.uid] = ck;
|
|
|
|
|
ck = datalist
|
|
|
|
|
gsCfg.saveBingStoken(this.e.user_id, datalist)
|
|
|
|
|
}
|
|
|
|
|
return ck[this.e.uid] || {}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return {}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-10 23:38:34 +08:00
|
|
|
|
async seachUid(data) {
|
2023-01-04 20:15:15 +08:00
|
|
|
|
let ltoken = '', v2Sk;
|
2022-11-10 23:38:34 +08:00
|
|
|
|
if (data?.data) {
|
|
|
|
|
let res;
|
|
|
|
|
if (this.e.sk) {
|
2023-01-04 20:15:15 +08:00
|
|
|
|
if (this.e.sk.get('stoken').includes('v2_')) {
|
|
|
|
|
res = await this.getData('getLtoken', { cookies: this.e.raw_message }, false)
|
|
|
|
|
ltoken = res?.data?.ltoken
|
|
|
|
|
} else {
|
|
|
|
|
v2Sk = await this.getData('getByStokenV2', { headers: { Cookie: this.e.raw_message } }, false)
|
2022-12-10 15:29:21 +08:00
|
|
|
|
}
|
2022-11-10 23:38:34 +08:00
|
|
|
|
this.e.cookie =
|
2022-12-08 15:44:13 +08:00
|
|
|
|
`ltoken=${this.e.sk?.get('ltoken') || ltoken};ltuid=${this.e.sk?.get('stuid')};cookie_token=${data.data.cookie_token}; account_id=${this.e.sk?.get('stuid')};`
|
2022-11-24 23:12:36 +08:00
|
|
|
|
// if(this.e.sk?.get('mid')){
|
|
|
|
|
// this.e.cookie =
|
|
|
|
|
// `ltoken_v2=${this.e.sk?.get('ltoken')||ltoken};cookie_token_v2=${data.data.cookie_token}; account_mid_v2=${this.e.sk.get('mid')};ltmid_v2=${this.e.sk.get('mid')}`
|
|
|
|
|
// }
|
2022-11-10 23:38:34 +08:00
|
|
|
|
} else {
|
2022-12-18 11:05:36 +08:00
|
|
|
|
this.e.cookie = this.e.original_msg //发送的为cookies
|
2023-01-04 20:15:15 +08:00
|
|
|
|
this.cookies = `stuid=${this.e.stuid};stoken=${data?.data?.list[0].token};ltoken=${data?.data?.list[1].token}`
|
|
|
|
|
res = await this.getData('getLtoken', { cookies: this.cookies }, false)
|
|
|
|
|
v2Sk = await this.getData('getByStokenV2', { headers: { Cookie: this.cookies } }, false)
|
2022-11-10 23:38:34 +08:00
|
|
|
|
}
|
|
|
|
|
res = await this.getData("userGameInfo", this.ForumData[1], false)
|
2022-12-08 15:44:13 +08:00
|
|
|
|
if (res?.retcode != 0) {
|
2022-11-25 09:45:32 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-03-09 23:45:55 +08:00
|
|
|
|
// console.log(res,this.e.sk)
|
2022-11-24 23:12:36 +08:00
|
|
|
|
let uids = []
|
2022-11-10 23:38:34 +08:00
|
|
|
|
for (let s of res.data.list) {
|
2022-11-21 11:31:03 +08:00
|
|
|
|
let datalist = {}
|
2022-11-10 23:38:34 +08:00
|
|
|
|
let uid = s.game_uid
|
|
|
|
|
uids.push(uid)
|
|
|
|
|
datalist[uid] = {
|
|
|
|
|
stuid: this.e?.sk?.get('stuid') || this.e.stuid,
|
2023-01-04 20:15:15 +08:00
|
|
|
|
stoken: v2Sk?.data?.token?.token || this.e?.sk?.get('stoken') || data?.data?.list[0].token,
|
2022-11-24 23:12:36 +08:00
|
|
|
|
ltoken: this.e?.sk?.get('ltoken') || ltoken || data?.data?.list[1].token,
|
2023-01-04 20:15:15 +08:00
|
|
|
|
mid: this.e?.sk?.get('mid') || v2Sk?.data?.user_info?.mid,
|
2022-11-10 23:38:34 +08:00
|
|
|
|
uid: uid,
|
|
|
|
|
userId: this.e.user_id,
|
|
|
|
|
is_sign: true
|
|
|
|
|
}
|
|
|
|
|
await gsCfg.saveBingStoken(this.e.user_id, datalist)
|
|
|
|
|
}
|
|
|
|
|
let msg = `uid:${uids.join(',')}\nstoken绑定成功您可通过下列指令进行操作:`;
|
|
|
|
|
msg += '\n【#米币查询】查询米游币余额'
|
|
|
|
|
msg += '\n【#mys原神签到】获取米游币'
|
|
|
|
|
msg += '\n【#更新抽卡记录】更新抽卡记录'
|
|
|
|
|
msg += '\n【#刷新ck】刷新失效cookie'
|
|
|
|
|
msg += '\n【#我的stoken】查看绑定信息'
|
|
|
|
|
msg += '\n【#删除stoken】删除绑定信息'
|
|
|
|
|
this.e.reply(msg)
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-18 00:11:15 +08:00
|
|
|
|
|
2022-10-12 16:51:51 +08:00
|
|
|
|
async delSytk(path = yamlDataUrl, e, type = "stoken") {
|
2022-09-05 11:49:06 +08:00
|
|
|
|
await this.getCookie(e);
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (type != "stoken") {
|
|
|
|
|
path = cloudDataUrl
|
|
|
|
|
}
|
2022-09-05 11:49:06 +08:00
|
|
|
|
let file = `${path}/${e.user_id}.yaml`
|
|
|
|
|
fs.exists(file, (exists) => {
|
|
|
|
|
if (!exists) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
let ck = fs.readFileSync(file, 'utf-8')
|
|
|
|
|
ck = YAML.parse(ck)
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (ck?.yuntoken) {
|
2022-09-05 11:49:06 +08:00
|
|
|
|
fs.unlinkSync(file);
|
2022-10-12 16:51:51 +08:00
|
|
|
|
} else if (ck) {
|
|
|
|
|
if (!ck[e.uid]) {
|
2022-09-05 11:49:06 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
delete ck[e.uid];
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (Object.keys(ck) == 0) {
|
2022-09-05 11:49:06 +08:00
|
|
|
|
fs.unlinkSync(file);
|
2022-10-12 16:51:51 +08:00
|
|
|
|
} else {
|
2022-09-05 11:49:06 +08:00
|
|
|
|
ck = YAML.stringify(ck)
|
|
|
|
|
fs.writeFileSync(file, ck, 'utf8')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
e.reply(`已删除${e.msg}`)
|
|
|
|
|
return true;
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
getDataList(name) {
|
|
|
|
|
for (let item of this.ForumData) {
|
|
|
|
|
if (item.name == name) { //循环结束未找到的时候返回原数组签到全部
|
|
|
|
|
return [item]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return this.ForumData;
|
|
|
|
|
}
|
2022-08-16 23:24:54 +08:00
|
|
|
|
}
|