2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-22 19:10:53 +08:00

新增cookies帮助指令

This commit is contained in:
Ctrlcvs 2022-07-29 22:43:28 +08:00 committed by leiyilu
parent bc1510bb37
commit 4f294bed11
5 changed files with 38 additions and 7 deletions

View File

@ -1,3 +1,13 @@
# 1.1.3
* 下列功能需要绑定`cookies`来跑非信任的bot请勿发送cookies
* 实现米游社多模块签到
* 实现米游社米游币获取
* 新增指令`cookies帮助`
* 新增指令`#米游社原神签到`
* 用于获取米游社米游币
* 新增指令`#崩坏3签到`
* 用于签到不同的社区模块
* 具体有`原神、崩坏3、崩坏2、未定事件簿、大别野、崩坏星穹铁道、绝区零`
# 1.1.2
* 初步实现米游社签到米游币以及社区签到
* 需要引入包文件`cnpm i promise-retry `跟`cnpm i superagent`

View File

@ -21,13 +21,13 @@ import {
} from "../components/Changelog.js";
import {
rule as signRule,
sign,mysSign
sign,mysSign,cookiesDocHelp
} from "./sign.js"
export {
updateRes,
updateMiaoPlugin,sign,
versionInfo,
Note_appoint,pokeNote,
Note_appoint,pokeNote,cookiesDocHelp,
sysCfg,
help,DailyNoteTask,
AtlasAlias,

View File

@ -10,7 +10,8 @@ import MysInfo from '../model/mys/mysInfo.js'
import {
isV3
} from '../components/Changelog.js';
import gsCfg from '../model/gsCfg.js'
import gsCfg from '../model/gsCfg.js';
export const rule = {
mysSign: {
reg: "^#*(米游社|mys|社区)(原神|崩坏3|崩坏2|未定事件簿|大别野|崩坏星穹铁道|绝区零|全部)签到$",
@ -19,6 +20,10 @@ export const rule = {
sign: {
reg: "^#*(原神|崩坏3|崩坏2|未定事件簿|大别野|崩坏星穹铁道|绝区零)签到$",
describe: "米社规则签到"
},
cookiesDocHelp: {
reg: "^#*(米游社|cookies|米游币)帮助$",
describe: "cookies获取帮助"
}
};
@ -30,6 +35,7 @@ const RETRY_OPTIONS = {
minTimeout: 5000,
maxTimeout: 10000
};
export async function sign(e) {
let isck=await cookie(e);
if (!isck) {
@ -167,8 +173,8 @@ async function cookie(e) {
let cookie, uid;
let miHoYoApi = new MihoYoApi(e);
let skuid;
let cookiesDoc=await getcookiesDoc();
if (isV3) {
// console.log(e)
skuid= await gsCfg.getBingCookie(e.user_id);
cookie = skuid.ck;
uid = skuid.item;
@ -182,12 +188,12 @@ async function cookie(e) {
}
}
if(!cookie){
e.reply("cookie失效请重新绑定~")
e.reply("cookie失效请重新绑定~【教程】\n"+cookiesDoc)
return false;
}
e.uid = uid;
if (!cookie.includes("login_ticket")&&(isV3&&!skuid?.login_ticket)) {
e.reply("米游社登录cookie不完整请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket")
e.reply("米游社登录cookie不完整请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket【教程】 "+cookiesDoc)
return false;
}
let flot = (await miHoYoApi.stoken(cookie, e));
@ -199,3 +205,11 @@ async function cookie(e) {
}
return true;
}
export async function cookiesDocHelp(e){
let cookiesDoc=await getcookiesDoc()
e.reply("【cookies帮助】"+cookiesDoc+"\ncookies必须包含login_ticket获取后请私发机器人");
return true
}
async function getcookiesDoc(){
return await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`,"config").cookiesDoc
}

2
config/config.yaml Normal file
View File

@ -0,0 +1,2 @@
# cookies教程
cookiesDoc: docs.qq.com/doc/DV2tDY2ltSFdtbU9z

View File

@ -47,6 +47,11 @@ class GsCfg {
}
}
getfileYaml(path,name){
return YAML.parse(
fs.readFileSync(path+name+".yaml", 'utf8')
)
}
/**
* 获取配置yaml
* @param app 功能