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

格式化代码

This commit is contained in:
ctrlcvs 2022-12-03 23:52:06 +08:00
parent 8a595232e2
commit b66750b84f
11 changed files with 103 additions and 111 deletions

View File

@ -1,6 +1,3 @@
import {
segment
} from "oicq";
import fs from "fs"; import fs from "fs";
import lodash from "lodash"; import lodash from "lodash";
import { import {
@ -14,9 +11,6 @@ import {
} from "../components/index.js"; } from "../components/index.js";
import Common from "../components/Common.js"; import Common from "../components/Common.js";
const require = createRequire(
import.meta.url);
let cfgMap = { let cfgMap = {
"体力": "sys.Note", "体力": "sys.Note",
"帮助": "sys.help", "帮助": "sys.help",

View File

@ -1,9 +1,6 @@
import { import {
Cfg Cfg
} from "../components/index.js"; } from "../components/index.js";
import {
segment
} from "oicq";
import lodash from "lodash"; import lodash from "lodash";
import { import {
currentVersion, currentVersion,

View File

@ -1,15 +1,8 @@
import miHoYoApi from "../model/mys/mihoyoApi.js"
import utils from '../model/mys/utils.js';
import User from "../model/user.js" import User from "../model/user.js"
import moment from 'moment'; import moment from 'moment';
import {
Cfg,
Data
} from "../components/index.js";
import { import {
segment segment
} from "oicq"; } from "oicq";
import user from "../model/user.js";
export const rule = { export const rule = {
sign: { sign: {
reg: `^#*(原神|崩坏3|崩坏2|未定事件簿)签到$`, reg: `^#*(原神|崩坏3|崩坏2|未定事件簿)签到$`,
@ -107,7 +100,6 @@ export async function bbsSign(e) {
await replyMsg(e, res.message); await replyMsg(e, res.message);
return true; return true;
} }
const _path = process.cwd();
let START; let START;
export async function sign(e) { export async function sign(e) {
let user = new User(e); let user = new User(e);

View File

@ -4,19 +4,14 @@ import {
Data Data
} from "../components/index.js"; } from "../components/index.js";
import moment from 'moment'; import moment from 'moment';
import lodash from 'lodash';
import Common from "../components/Common.js"; import Common from "../components/Common.js";
import { 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"; import fs from "fs";
import {
segment
} from "oicq";
import YAML from 'yaml' import YAML from 'yaml'
import User from "../model/user.js" import User from "../model/user.js"
import user from '../model/user.js';
export const rule = { export const rule = {
userInfo: { userInfo: {
@ -87,10 +82,9 @@ export async function userInfo(e, {
render, render,
scale: 1.2 scale: 1.2
}) })
return true;
} }
let configData = gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config"); let configData = gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config");
export async function gcPaylog(e){ export async function gcPaylog(e) {
let user = new User(e); let user = new User(e);
await user.cookie(e) await user.cookie(e)
let redis_Data = await redis.get(`xiaoyao:gcPaylog:${e.user_id}`); let redis_Data = await redis.get(`xiaoyao:gcPaylog:${e.user_id}`);
@ -99,16 +93,16 @@ export async function gcPaylog(e){
e.reply(`请求过快,请${time}秒后重试...`); e.reply(`请求过快,请${time}秒后重试...`);
return true; return true;
} }
let isGet= /导出|获取/.test(e.msg) let isGet = /导出|获取/.test(e.msg)
if (!e.isPrivate&&isGet) { if (!e.isPrivate && isGet) {
e.reply("请私聊发送") e.reply("请私聊发送")
return true; return true;
} }
let authkey =await getAuthKey(e,user) let authkey = await getAuthKey(e, user)
if(!authkey){ if (!authkey) {
return true; return true;
} }
let url =`https://hk4e-api.mihoyo.com/ysulog/api/getCrystalLog?selfquery_type=3&lang=zh-cn&sign_type=2&auth_appid=csc&authkey_ver=1&authkey=${encodeURIComponent(authkey)}&game_biz=hk4e_cn&app_client=bbs&type=3&size=6&region=${e.region}&end_id=` let url = `https://hk4e-api.mihoyo.com/ysulog/api/getCrystalLog?selfquery_type=3&lang=zh-cn&sign_type=2&auth_appid=csc&authkey_ver=1&authkey=${encodeURIComponent(authkey)}&game_biz=hk4e_cn&app_client=bbs&type=3&size=6&region=${e.region}&end_id=`
e.msg = url e.msg = url
// e.reply(e.msg) // e.reply(e.msg)
let sendMsg = []; let sendMsg = [];
@ -117,18 +111,18 @@ export async function gcPaylog(e){
e.reply = (msg) => { e.reply = (msg) => {
sendMsg.push(msg) sendMsg.push(msg)
} }
if(isGet){ if (isGet) {
sendMsg=[...sendMsg,...[1,`uid:${e.uid}`,e.msg]] sendMsg = [...sendMsg, ...[1, `uid:${e.uid}`, e.msg]]
}else { } else {
let time = (configData.gclogEx || 5) * 60 let time = (configData.gclogEx || 5) * 60
redis.set(`xiaoyao:gcPaylog:${e.user_id}`, Math.floor(Date.now() / 1000) + time, { //数据写入缓存避免重复请求 redis.set(`xiaoyao:gcPaylog:${e.user_id}`, Math.floor(Date.now() / 1000) + time, { //数据写入缓存避免重复请求
EX: time EX: time
}); });
if (isV3) { if (isV3) {
let {payLog} = (await import(`file:///${_path}/plugins/genshin/apps/payLog.js`)) let { payLog } = (await import(`file:///${_path}/plugins/genshin/apps/payLog.js`))
let pl= (new payLog()) let pl = (new payLog())
e.isGroup=false; e.isGroup = false;
pl.e=e pl.e = e
await pl.getAuthKey(e) await pl.getAuthKey(e)
e._reply(sendMsg[1]); e._reply(sendMsg[1]);
return true; return true;
@ -136,12 +130,6 @@ export async function gcPaylog(e){
} else { } else {
e._reply(`V2暂不支持`); e._reply(`V2暂不支持`);
return false return false
//V2暂不支持
// let {
// bing
// } = (await import(`file:///${_path}/lib/app/gachaLog.js`))
// e.isPrivate = true;
// await bing(e)
} }
} }
await utils.replyMake(e, sendMsg, 1) await utils.replyMake(e, sendMsg, 1)
@ -156,13 +144,13 @@ export async function gclog(e) {
e.reply(`请求过快,请${time}秒后重试...`); e.reply(`请求过快,请${time}秒后重试...`);
return true; return true;
} }
let isGet= /导出|获取/.test(e.msg) let isGet = /导出|获取/.test(e.msg)
if (!e.isPrivate&&isGet) { if (!e.isPrivate && isGet) {
e.reply("请私聊发送") e.reply("请私聊发送")
return true; return true;
} }
let authkey =await getAuthKey(e,user) let authkey = await getAuthKey(e, user)
if(!authkey){ if (!authkey) {
return true; return true;
} }
let url = `https://hk4e-api.mihoyo.com/event/gacha_info/api/getGachaLog?authkey_ver=1&sign_type=2&auth_appid=webview_gacha&init_type=301&gacha_id=fecafa7b6560db5f3182222395d88aaa6aaac1bc&timestamp=${Math.floor(Date.now() / 1000)}&lang=zh-cn&device_type=mobile&plat_type=ios&region=${e.region}&authkey=${encodeURIComponent(authkey)}&game_biz=hk4e_cn&gacha_type=301&page=1&size=5&end_id=0` let url = `https://hk4e-api.mihoyo.com/event/gacha_info/api/getGachaLog?authkey_ver=1&sign_type=2&auth_appid=webview_gacha&init_type=301&gacha_id=fecafa7b6560db5f3182222395d88aaa6aaac1bc&timestamp=${Math.floor(Date.now() / 1000)}&lang=zh-cn&device_type=mobile&plat_type=ios&region=${e.region}&authkey=${encodeURIComponent(authkey)}&game_biz=hk4e_cn&gacha_type=301&page=1&size=5&end_id=0`
@ -174,9 +162,9 @@ export async function gclog(e) {
e.reply = (msg) => { e.reply = (msg) => {
sendMsg.push(msg) sendMsg.push(msg)
} }
if(isGet){ if (isGet) {
sendMsg=[...sendMsg,...[1,`uid:${e.uid}`,e.msg]] sendMsg = [...sendMsg, ...[1, `uid:${e.uid}`, e.msg]]
}else { } else {
if (isV3) { if (isV3) {
let gclog = (await import(`file:///${_path}/plugins/genshin/model/gachaLog.js`)).default let gclog = (await import(`file:///${_path}/plugins/genshin/model/gachaLog.js`)).default
await (new gclog(e)).logUrl() await (new gclog(e)).logUrl()
@ -195,11 +183,11 @@ export async function gclog(e) {
}); });
return true; return true;
} }
async function getAuthKey(e,user){ async function getAuthKey(e, user) {
e.region = getServer(e.uid) e.region = getServer(e.uid)
let authkeyrow = await user.getData("authKey"); let authkeyrow = await user.getData("authKey");
if (!authkeyrow?.data) { if (!authkeyrow?.data) {
e.reply("authkey获取失败" +(authkeyrow.message.includes("登录失效")?"请重新绑定stoken":authkeyrow.message)) e.reply("authkey获取失败" + (authkeyrow.message.includes("登录失效") ? "请重新绑定stoken" : authkeyrow.message))
return false; return false;
} }
return authkeyrow.data["authkey"]; return authkeyrow.data["authkey"];
@ -228,18 +216,22 @@ export async function mytoken(e) {
return true; return true;
} }
export async function bindLogin_ticket(e){ export async function bindLogin_ticket(e) {
if (!e.isPrivate) {
e.reply("请私聊发送")
return true;
}
let user = new User(e); let user = new User(e);
let ckMap=await utils.getCookieMap(e.original_msg.replace(/'|"/g,"")) let ckMap = await utils.getCookieMap(e.original_msg.replace(/'|"/g, ""))
let stuid=ckMap?.get("login_uid") ? ckMap?.get("login_uid") : ckMap?.get("ltuid") let stuid = ckMap?.get("login_uid") ? ckMap?.get("login_uid") : ckMap?.get("ltuid")
if(!stuid) stuid= ckMap?.get("account_id"); if (!stuid) stuid = ckMap?.get("account_id");
if(ckMap&&Cfg.get("ck.sk")){ if (ckMap && Cfg.get("ck.sk")) {
let res= await user.getData("bbsStoken", { let res = await user.getData("bbsStoken", {
loginUid:stuid, loginUid: stuid,
loginTicket:ckMap.get("login_ticket"), loginTicket: ckMap.get("login_ticket"),
}) })
if(res?.retcode===0){ if (res?.retcode === 0) {
e.stuid=stuid; e.stuid = stuid;
await user.seachUid(res) await user.seachUid(res)
} }
} }
@ -255,8 +247,8 @@ export async function bindStoken(e) {
let user = new User(e); let user = new User(e);
await user.cookie(e) await user.cookie(e)
e.region = getServer(e.uid) e.region = getServer(e.uid)
e.cks=msg.replace(/;/g,'&').replace(/stuid/,"uid") e.cks = msg.replace(/;/g, '&').replace(/stuid/, "uid")
let res= await user.getData("bbsGetCookie",{cookies:e.cks}) let res = await user.getData("bbsGetCookie", { cookies: e.cks })
if (!res?.data) { if (!res?.data) {
await e.reply(`绑定Stoken失败异常${res?.message}\n请发送【stoken帮助】查看配置教程重新配置~`); await e.reply(`绑定Stoken失败异常${res?.message}\n请发送【stoken帮助】查看配置教程重新配置~`);
return true; return true;
@ -283,7 +275,7 @@ export async function cloudToken(e) {
let yuntoken = msg[0]; let yuntoken = msg[0];
e.devId = devId; e.devId = devId;
e.yuntoken = yuntoken; e.yuntoken = yuntoken;
let res=await user.cloudSeach() let res = await user.cloudSeach()
if (res.retcode != 0) { if (res.retcode != 0) {
e.reply(res.message) e.reply(res.message)
return true; return true;
@ -309,13 +301,13 @@ export async function delSign(e) {
return true; return true;
} }
export async function updCookie(e) { export async function updCookie(e) {
let stoken=await gsCfg.getUserStoken(e.user_id); let stoken = await gsCfg.getUserStoken(e.user_id);
if (Object.keys(stoken).length==0) { if (Object.keys(stoken).length == 0) {
e.reply("请先绑定stoken\n发送【stoken帮助】查看配置教程") e.reply("请先绑定stoken\n发送【stoken帮助】查看配置教程")
return true; return true;
} }
let isGet= e.msg.includes("获取") let isGet = e.msg.includes("获取")
if (!e.isPrivate&&isGet) { if (!e.isPrivate && isGet) {
e.reply("请私聊发送") e.reply("请私聊发送")
return true; return true;
} }
@ -325,19 +317,19 @@ export async function updCookie(e) {
e.reply = (msg) => { e.reply = (msg) => {
sendMsg.push(msg) sendMsg.push(msg)
} }
for(let item of Object.keys(stoken)){ for (let item of Object.keys(stoken)) {
e.region = getServer(stoken[item].uid) e.region = getServer(stoken[item].uid)
e.uid=stoken[item].uid e.uid = stoken[item].uid
let res= await user.getData("bbsGetCookie",{cookies:`uid=${stoken[item].stuid}&stoken=${stoken[item].stoken}`},false) let res = await user.getData("bbsGetCookie", { cookies: `uid=${stoken[item].stuid}&stoken=${stoken[item].stoken}` }, false)
if (!res?.data) { if (!res?.data) {
e.reply(`uid:${stoken[item].uid},请求异常:${res.message}`) e.reply(`uid:${stoken[item].uid},请求异常:${res.message}`)
continue; continue;
} }
let ck = res["data"]["cookie_token"]; let ck = res["data"]["cookie_token"];
e.msg = `ltoken=${stoken[item].ltoken};ltuid=${stoken[item].stuid};cookie_token=${ck}; account_id=${stoken[item].stuid};` e.msg = `ltoken=${stoken[item].ltoken};ltuid=${stoken[item].stuid};cookie_token=${ck}; account_id=${stoken[item].stuid};`
if(isGet){ if (isGet) {
sendMsg=[...sendMsg,...[`uid:${stoken[item].uid}`,e.msg]] sendMsg = [...sendMsg, ...[`uid:${stoken[item].uid}`, e.msg]]
}else { } else {
if (isV3) { if (isV3) {
let userck = (await import(`file:///${_path}/plugins/genshin/model/user.js`)).default let userck = (await import(`file:///${_path}/plugins/genshin/model/user.js`)).default
e.ck = e.msg; e.ck = e.msg;
@ -355,7 +347,7 @@ export async function updCookie(e) {
return true; return true;
} }
function getServer (uid) { function getServer(uid) {
switch (String(uid)[0]) { switch (String(uid)[0]) {
case '1': case '1':
case '2': case '2':

View File

@ -5,16 +5,12 @@ import fs from "fs";
import { import {
Cfg Cfg
} from "../components/index.js"; } from "../components/index.js";
import Data from "../components/Data.js"
import path from 'path';
import fetch from "node-fetch";
import gsCfg from '../model/gsCfg.js' import gsCfg from '../model/gsCfg.js'
import { import {
isV3 isV3
} from '../components/Changelog.js' } from '../components/Changelog.js'
import utils from "../model/mys/utils.js"; import utils from "../model/mys/utils.js";
const _path = process.cwd(); const _path = process.cwd();
const __dirname = path.resolve();
const list = ["wuqi_tujian", "shiwu_tujian", "yuanmo_tujian", "mijin_tujian", "shengyiwu_tujian", "daoju_tujian"] const list = ["wuqi_tujian", "shiwu_tujian", "yuanmo_tujian", "mijin_tujian", "shengyiwu_tujian", "daoju_tujian"]
const reglist = ["(#|专武|武器|图鉴)", "(#|食物|特殊料理|特色|料理|食材|图鉴)", "(#|原魔|怪物|图鉴|信息)", "(#|秘境|信息|图鉴)", "(#|圣遗物|图鉴|本|套)", const reglist = ["(#|专武|武器|图鉴)", "(#|食物|特殊料理|特色|料理|食材|图鉴)", "(#|原魔|怪物|图鉴|信息)", "(#|秘境|信息|图鉴)", "(#|圣遗物|图鉴|本|套)",

View File

@ -1,20 +1,13 @@
import YAML from 'yaml' import YAML from 'yaml'
import chokidar from 'chokidar'
import fs from 'node:fs' import fs from 'node:fs'
import { import {
promisify promisify
} from 'node:util' } from 'node:util'
import lodash from 'lodash' import lodash from 'lodash'
import {
Data
} from "../components/index.js";
import { import {
isV3 isV3
} from '../components/Changelog.js'; } from '../components/Changelog.js';
import utils from './mys/utils.js';
const plugin = "xiaoyao-cvs-plugin" const plugin = "xiaoyao-cvs-plugin"
const pathPlugin=`./plugins/${plugin}/data/`
/** /**
* 配置文件 * 配置文件
* 主要用于处理 stoken以及云原神账号数据 * 主要用于处理 stoken以及云原神账号数据

View File

@ -122,7 +122,7 @@ export default class miHoYoApi {
let urlMap = { let urlMap = {
userGameInfo: { //通用查询 userGameInfo: { //通用查询
url: `${this.apiMap.apiWeb}/binding/api/getUserGameRolesByCookie`, url: `${this.apiMap.apiWeb}/binding/api/getUserGameRolesByCookie`,
query: `game_biz=${this.isOs?board?.osbiz:board?.biz}`, query: `game_biz=${this.isOs ? board?.osbiz : board?.biz}`,
types: 'sign' types: 'sign'
}, },
isSign: board?.signUrl(data, "isSign", this.apiMap.apiWeb) || {}, isSign: board?.signUrl(data, "isSign", this.apiMap.apiWeb) || {},
@ -152,11 +152,11 @@ export default class miHoYoApi {
}, },
bbsCaptchaVerify: { bbsCaptchaVerify: {
url: `${mys.bbs_api}/misc/api/verifyVerification`, url: `${mys.bbs_api}/misc/api/verifyVerification`,
types:'bbs' types: 'bbs'
}, },
bbsCaptchaVerify: { bbsCaptchaVerify: {
url: `https://api.geetest.com/gettype.php`, url: `https://api.geetest.com/gettype.php`,
query:`` query: ``
}, },
//待定接口 用于获取用户米游社顶部的模块栏 //待定接口 用于获取用户米游社顶部的模块栏
bbs_Businesses_url: { bbs_Businesses_url: {

View File

@ -1,5 +1,4 @@
import YAML from 'yaml' import YAML from 'yaml'
import chokidar from 'chokidar'
import miHoYoApi from "../model/mys/mihoyoApi.js" import miHoYoApi from "../model/mys/mihoyoApi.js"
import fs from 'node:fs' import fs from 'node:fs'
import lodash from 'lodash' import lodash from 'lodash'
@ -15,11 +14,6 @@ import {
import moment from 'moment' import moment from 'moment'
const _path = process.cwd(); const _path = process.cwd();
const plugin = "xiaoyao-cvs-plugin" const plugin = "xiaoyao-cvs-plugin"
const RETRY_OPTIONS = {
retries: 3,
minTimeout: 5000,
maxTimeout: 10000
};
const nameData = ["原神", "崩坏3", "崩坏2", "未定事件簿"]; const nameData = ["原神", "崩坏3", "崩坏2", "未定事件簿"];
const yamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`; const yamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`;
const cloudDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yunToken/` const cloudDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yunToken/`

View File

@ -33,6 +33,7 @@
- 冬极 - 冬极
- 冬季 - 冬季
- 公子 - 公子
- 白星
- 达达利亚 - 达达利亚
- 鸭鸭 - 鸭鸭
- 达达鸭 - 达达鸭

View File

@ -450,11 +450,13 @@
- 火使徒 - 火使徒
- 火咏者 - 火咏者
- 深渊使徒渊火 - 深渊使徒渊火
- 深渊咏者渊火
深渊咏者·紫电: 深渊咏者·紫电:
- 紫电 - 紫电
- 雷使徒 - 雷使徒
- 雷咏者 - 雷咏者
- 深渊使徒紫电 - 深渊使徒紫电
- 深渊咏者紫电
火深渊法师: 火深渊法师:
- 火法师 - 火法师
- 火法 - 火法

View File

@ -41,6 +41,37 @@ export const helpList = [{
"desc": "重写原有的查询当前米游社体力" "desc": "重写原有的查询当前米游社体力"
}, },
] ]
},{
"group": "stoken功能",
"list": [{
"icon": 75,
"title": "#更新抽卡记录",
"desc": "(更新|获取) 抽卡记录"
},
{
"icon": 74,
"title": "#mys原神签到",
"desc": "社区米游币获取(由于有验证码大概会失败)"
},
{
"icon": 92,
"title": "#刷新ck",
"desc": "重置当前cookie"
},
]
},{
"group": "其他功能",
"list": [{
"icon": 77,
"title": "#云原神签到",
"desc": "云原神签到"
},
{
"icon": 78,
"title": "#崩坏三签到",
"desc": "其余模块签到支持崩坏3|崩坏2|未定义)"
},
]
},{ },{
"group": "管理命令,仅管理员可用", "group": "管理命令,仅管理员可用",
"auth": "master", "auth": "master",