diff --git a/apps/admin.js b/apps/admin.js index e0f0379..30d8ee2 100644 --- a/apps/admin.js +++ b/apps/admin.js @@ -1,6 +1,3 @@ -import { - segment -} from "oicq"; import fs from "fs"; import lodash from "lodash"; import { @@ -14,9 +11,6 @@ import { } from "../components/index.js"; import Common from "../components/Common.js"; - -const require = createRequire( - import.meta.url); let cfgMap = { "体力": "sys.Note", "帮助": "sys.help", diff --git a/apps/help.js b/apps/help.js index 7792a06..233d6fa 100644 --- a/apps/help.js +++ b/apps/help.js @@ -1,9 +1,6 @@ import { Cfg } from "../components/index.js"; -import { - segment -} from "oicq"; import lodash from "lodash"; import { currentVersion, diff --git a/apps/sign.js b/apps/sign.js index 7988343..eaf96e3 100644 --- a/apps/sign.js +++ b/apps/sign.js @@ -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 moment from 'moment'; -import { - Cfg, - Data -} from "../components/index.js"; import { segment } from "oicq"; -import user from "../model/user.js"; export const rule = { sign: { reg: `^#*(原神|崩坏3|崩坏2|未定事件簿)签到$`, @@ -107,7 +100,6 @@ export async function bbsSign(e) { await replyMsg(e, res.message); return true; } -const _path = process.cwd(); let START; export async function sign(e) { let user = new User(e); diff --git a/apps/user.js b/apps/user.js index 5cd8f4e..b748c82 100644 --- a/apps/user.js +++ b/apps/user.js @@ -4,19 +4,14 @@ import { Data } from "../components/index.js"; import moment from 'moment'; -import lodash from 'lodash'; import Common from "../components/Common.js"; import { isV3 } from '../components/Changelog.js'; import gsCfg from '../model/gsCfg.js'; import fs from "fs"; -import { - segment -} from "oicq"; import YAML from 'yaml' import User from "../model/user.js" -import user from '../model/user.js'; export const rule = { userInfo: { @@ -87,10 +82,9 @@ export async function userInfo(e, { render, scale: 1.2 }) - return true; } 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); await user.cookie(e) let redis_Data = await redis.get(`xiaoyao:gcPaylog:${e.user_id}`); @@ -99,16 +93,16 @@ export async function gcPaylog(e){ e.reply(`请求过快,请${time}秒后重试...`); return true; } - let isGet= /导出|获取/.test(e.msg) - if (!e.isPrivate&&isGet) { + let isGet = /导出|获取/.test(e.msg) + if (!e.isPrivate && isGet) { e.reply("请私聊发送") return true; } - let authkey =await getAuthKey(e,user) - if(!authkey){ + let authkey = await getAuthKey(e, user) + if (!authkey) { 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®ion=${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®ion=${e.region}&end_id=` e.msg = url // e.reply(e.msg) let sendMsg = []; @@ -117,18 +111,18 @@ export async function gcPaylog(e){ e.reply = (msg) => { sendMsg.push(msg) } - if(isGet){ - sendMsg=[...sendMsg,...[1,`uid:${e.uid}`,e.msg]] - }else { + if (isGet) { + sendMsg = [...sendMsg, ...[1, `uid:${e.uid}`, e.msg]] + } else { let time = (configData.gclogEx || 5) * 60 redis.set(`xiaoyao:gcPaylog:${e.user_id}`, Math.floor(Date.now() / 1000) + time, { //数据写入缓存避免重复请求 EX: time }); if (isV3) { - let {payLog} = (await import(`file:///${_path}/plugins/genshin/apps/payLog.js`)) - let pl= (new payLog()) - e.isGroup=false; - pl.e=e + let { payLog } = (await import(`file:///${_path}/plugins/genshin/apps/payLog.js`)) + let pl = (new payLog()) + e.isGroup = false; + pl.e = e await pl.getAuthKey(e) e._reply(sendMsg[1]); return true; @@ -136,12 +130,6 @@ export async function gcPaylog(e){ } else { e._reply(`V2暂不支持`); 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) @@ -156,13 +144,13 @@ export async function gclog(e) { e.reply(`请求过快,请${time}秒后重试...`); return true; } - let isGet= /导出|获取/.test(e.msg) - if (!e.isPrivate&&isGet) { + let isGet = /导出|获取/.test(e.msg) + if (!e.isPrivate && isGet) { e.reply("请私聊发送") return true; } - let authkey =await getAuthKey(e,user) - if(!authkey){ + let authkey = await getAuthKey(e, user) + if (!authkey) { 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×tamp=${Math.floor(Date.now() / 1000)}&lang=zh-cn&device_type=mobile&plat_type=ios®ion=${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) => { sendMsg.push(msg) } - if(isGet){ - sendMsg=[...sendMsg,...[1,`uid:${e.uid}`,e.msg]] - }else { + if (isGet) { + sendMsg = [...sendMsg, ...[1, `uid:${e.uid}`, e.msg]] + } else { if (isV3) { let gclog = (await import(`file:///${_path}/plugins/genshin/model/gachaLog.js`)).default await (new gclog(e)).logUrl() @@ -195,11 +183,11 @@ export async function gclog(e) { }); return true; } -async function getAuthKey(e,user){ +async function getAuthKey(e, user) { e.region = getServer(e.uid) let authkeyrow = await user.getData("authKey"); if (!authkeyrow?.data) { - e.reply("authkey获取失败:" +(authkeyrow.message.includes("登录失效")?"请重新绑定stoken":authkeyrow.message)) + e.reply("authkey获取失败:" + (authkeyrow.message.includes("登录失效") ? "请重新绑定stoken" : authkeyrow.message)) return false; } return authkeyrow.data["authkey"]; @@ -228,18 +216,22 @@ export async function mytoken(e) { 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 ckMap=await utils.getCookieMap(e.original_msg.replace(/'|"/g,"")) - let stuid=ckMap?.get("login_uid") ? ckMap?.get("login_uid") : ckMap?.get("ltuid") - if(!stuid) stuid= ckMap?.get("account_id"); - if(ckMap&&Cfg.get("ck.sk")){ - let res= await user.getData("bbsStoken", { - loginUid:stuid, - loginTicket:ckMap.get("login_ticket"), + let ckMap = await utils.getCookieMap(e.original_msg.replace(/'|"/g, "")) + let stuid = ckMap?.get("login_uid") ? ckMap?.get("login_uid") : ckMap?.get("ltuid") + if (!stuid) stuid = ckMap?.get("account_id"); + if (ckMap && Cfg.get("ck.sk")) { + let res = await user.getData("bbsStoken", { + loginUid: stuid, + loginTicket: ckMap.get("login_ticket"), }) - if(res?.retcode===0){ - e.stuid=stuid; + if (res?.retcode === 0) { + e.stuid = stuid; await user.seachUid(res) } } @@ -255,8 +247,8 @@ export async function bindStoken(e) { let user = new User(e); await user.cookie(e) e.region = getServer(e.uid) - e.cks=msg.replace(/;/g,'&').replace(/stuid/,"uid") - let res= await user.getData("bbsGetCookie",{cookies:e.cks}) + e.cks = msg.replace(/;/g, '&').replace(/stuid/, "uid") + let res = await user.getData("bbsGetCookie", { cookies: e.cks }) if (!res?.data) { await e.reply(`绑定Stoken失败,异常:${res?.message}\n请发送【stoken帮助】查看配置教程重新配置~`); return true; @@ -283,7 +275,7 @@ export async function cloudToken(e) { let yuntoken = msg[0]; e.devId = devId; e.yuntoken = yuntoken; - let res=await user.cloudSeach() + let res = await user.cloudSeach() if (res.retcode != 0) { e.reply(res.message) return true; @@ -309,13 +301,13 @@ export async function delSign(e) { return true; } export async function updCookie(e) { - let stoken=await gsCfg.getUserStoken(e.user_id); - if (Object.keys(stoken).length==0) { + let stoken = await gsCfg.getUserStoken(e.user_id); + if (Object.keys(stoken).length == 0) { e.reply("请先绑定stoken\n发送【stoken帮助】查看配置教程") return true; } - let isGet= e.msg.includes("获取") - if (!e.isPrivate&&isGet) { + let isGet = e.msg.includes("获取") + if (!e.isPrivate && isGet) { e.reply("请私聊发送") return true; } @@ -325,19 +317,19 @@ export async function updCookie(e) { e.reply = (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.uid=stoken[item].uid - let res= await user.getData("bbsGetCookie",{cookies:`uid=${stoken[item].stuid}&stoken=${stoken[item].stoken}`},false) + e.uid = stoken[item].uid + let res = await user.getData("bbsGetCookie", { cookies: `uid=${stoken[item].stuid}&stoken=${stoken[item].stoken}` }, false) if (!res?.data) { e.reply(`uid:${stoken[item].uid},请求异常:${res.message}`) continue; } let ck = res["data"]["cookie_token"]; e.msg = `ltoken=${stoken[item].ltoken};ltuid=${stoken[item].stuid};cookie_token=${ck}; account_id=${stoken[item].stuid};` - if(isGet){ - sendMsg=[...sendMsg,...[`uid:${stoken[item].uid}`,e.msg]] - }else { + if (isGet) { + sendMsg = [...sendMsg, ...[`uid:${stoken[item].uid}`, e.msg]] + } else { if (isV3) { let userck = (await import(`file:///${_path}/plugins/genshin/model/user.js`)).default e.ck = e.msg; @@ -355,21 +347,21 @@ export async function updCookie(e) { return true; } -function getServer (uid) { - switch (String(uid)[0]) { - case '1': - case '2': - return 'cn_gf01' // 官服 - case '5': - return 'cn_qd01' // B服 - case '6': - return 'os_usa' // 美服 - case '7': - return 'os_euro' // 欧服 - case '8': - return 'os_asia' // 亚服 - case '9': - return 'os_cht' // 港澳台服 - } - return 'cn_gf01' +function getServer(uid) { + switch (String(uid)[0]) { + case '1': + case '2': + return 'cn_gf01' // 官服 + case '5': + return 'cn_qd01' // B服 + case '6': + return 'os_usa' // 美服 + case '7': + return 'os_euro' // 欧服 + case '8': + return 'os_asia' // 亚服 + case '9': + return 'os_cht' // 港澳台服 + } + return 'cn_gf01' } \ No newline at end of file diff --git a/apps/xiaoyao_image.js b/apps/xiaoyao_image.js index b9047b9..a3e912e 100644 --- a/apps/xiaoyao_image.js +++ b/apps/xiaoyao_image.js @@ -5,16 +5,12 @@ import fs from "fs"; import { Cfg } 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 { isV3 } from '../components/Changelog.js' import utils from "../model/mys/utils.js"; const _path = process.cwd(); -const __dirname = path.resolve(); const list = ["wuqi_tujian", "shiwu_tujian", "yuanmo_tujian", "mijin_tujian", "shengyiwu_tujian", "daoju_tujian"] const reglist = ["(#|专武|武器|图鉴)", "(#|食物|特殊料理|特色|料理|食材|图鉴)", "(#|原魔|怪物|图鉴|信息)", "(#|秘境|信息|图鉴)", "(#|圣遗物|图鉴|本|套)", diff --git a/model/gsCfg.js b/model/gsCfg.js index e61ff99..c53f756 100644 --- a/model/gsCfg.js +++ b/model/gsCfg.js @@ -1,20 +1,13 @@ import YAML from 'yaml' -import chokidar from 'chokidar' import fs from 'node:fs' import { promisify } from 'node:util' import lodash from 'lodash' -import { - Data -} from "../components/index.js"; - import { isV3 } from '../components/Changelog.js'; -import utils from './mys/utils.js'; const plugin = "xiaoyao-cvs-plugin" -const pathPlugin=`./plugins/${plugin}/data/` /** * 配置文件 * 主要用于处理 stoken以及云原神账号数据 diff --git a/model/mys/mihoyoApi.js b/model/mys/mihoyoApi.js index 672f82e..df71b85 100644 --- a/model/mys/mihoyoApi.js +++ b/model/mys/mihoyoApi.js @@ -122,7 +122,7 @@ export default class miHoYoApi { let urlMap = { userGameInfo: { //通用查询 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' }, isSign: board?.signUrl(data, "isSign", this.apiMap.apiWeb) || {}, @@ -152,11 +152,11 @@ export default class miHoYoApi { }, bbsCaptchaVerify: { url: `${mys.bbs_api}/misc/api/verifyVerification`, - types:'bbs' + types: 'bbs' }, bbsCaptchaVerify: { url: `https://api.geetest.com/gettype.php`, - query:`` + query: `` }, //待定接口 用于获取用户米游社顶部的模块栏 bbs_Businesses_url: { diff --git a/model/user.js b/model/user.js index 8a8527a..283da20 100644 --- a/model/user.js +++ b/model/user.js @@ -1,5 +1,4 @@ import YAML from 'yaml' -import chokidar from 'chokidar' import miHoYoApi from "../model/mys/mihoyoApi.js" import fs from 'node:fs' import lodash from 'lodash' @@ -15,11 +14,6 @@ import { import moment from 'moment' const _path = process.cwd(); const plugin = "xiaoyao-cvs-plugin" -const RETRY_OPTIONS = { - retries: 3, - minTimeout: 5000, - maxTimeout: 10000 -}; const nameData = ["原神", "崩坏3", "崩坏2", "未定事件簿"]; const yamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`; const cloudDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yunToken/` diff --git a/resources/Atlas_alias/wuqi_tujian.yaml b/resources/Atlas_alias/wuqi_tujian.yaml index 7aedc9b..972bbec 100644 --- a/resources/Atlas_alias/wuqi_tujian.yaml +++ b/resources/Atlas_alias/wuqi_tujian.yaml @@ -33,6 +33,7 @@ - 冬极 - 冬季 - 公子 + - 白星 - 达达利亚 - 鸭鸭 - 达达鸭 diff --git a/resources/Atlas_alias/yuanmo_tujian.yaml b/resources/Atlas_alias/yuanmo_tujian.yaml index 8765747..49fcdfa 100644 --- a/resources/Atlas_alias/yuanmo_tujian.yaml +++ b/resources/Atlas_alias/yuanmo_tujian.yaml @@ -450,11 +450,13 @@ - 火使徒 - 火咏者 - 深渊使徒渊火 + - 深渊咏者渊火 深渊咏者·紫电: - 紫电 - 雷使徒 - 雷咏者 - 深渊使徒紫电 + - 深渊咏者紫电 火深渊法师: - 火法师 - 火法 diff --git a/resources/help/help-cfg_default.js b/resources/help/help-cfg_default.js index 62b9f80..3a1ba35 100644 --- a/resources/help/help-cfg_default.js +++ b/resources/help/help-cfg_default.js @@ -41,6 +41,37 @@ export const helpList = [{ "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": "管理命令,仅管理员可用", "auth": "master",