2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 03:20:52 +08:00
This commit is contained in:
Ctrlcvs 2023-05-18 09:55:57 +08:00
commit c27148f469
5 changed files with 51 additions and 28 deletions

View File

@ -1,8 +1,14 @@
import User from "../model/user.js" import User from "../model/user.js"
import moment from 'moment'; import moment from 'moment';
import lodash from 'lodash'
import {
Data
} from "../components/index.js";
const _path = process.cwd();
let ForumData = Data.readJSON(`${_path}/plugins/xiaoyao-cvs-plugin/defSet/json`, "mys")
export const rule = { export const rule = {
sign: { sign: {
reg: `^#*(原神|崩坏3|崩坏2|未定事件簿|崩坏星穹铁道)签到$`, reg: `^#*(${lodash.map(ForumData,v=> v.otherName.join('|')).join('|')}|游戏)签到$`,
describe: "米社规则签到" describe: "米社规则签到"
}, },
bbsSign: { bbsSign: {

View File

@ -3,42 +3,49 @@
"id": "1", "id": "1",
"forumId": "1", "forumId": "1",
"name": "崩坏3", "name": "崩坏3",
"url": "https://bbs.mihoyo.com/bh3/" "url": "https://bbs.mihoyo.com/bh3/",
"otherName":["bh3","崩崩崩","崩坏3"]
}, },
{ {
"id": "2", "id": "2",
"forumId": "26", "forumId": "26",
"name": "原神", "name": "原神",
"url": "https://bbs.mihoyo.com/ys/" "url": "https://bbs.mihoyo.com/ys/",
"otherName":["原神"]
}, },
{ {
"id": "3", "id": "3",
"forumId": "30", "forumId": "30",
"name": "崩坏2", "name": "崩坏2",
"url": "https://bbs.mihoyo.com/bh2/" "url": "https://bbs.mihoyo.com/bh2/",
"otherName":["bh2","崩崩","崩坏2"]
}, },
{ {
"id": "4", "id": "4",
"forumId": "37", "forumId": "37",
"name": "未定事件簿", "name": "未定事件簿",
"url": "https://bbs.mihoyo.com/wd/" "url": "https://bbs.mihoyo.com/wd/",
"otherName":["事件簿","未定事件簿","未定"]
}, },
{ {
"id": "5", "id": "5",
"forumId": "34", "forumId": "34",
"name": "大别野", "name": "大别野",
"url": "https://bbs.mihoyo.com/dby/" "url": "https://bbs.mihoyo.com/dby/",
"otherName":["大别野"]
}, },
{ {
"id": "6", "id": "6",
"forumId": "52", "forumId": "52",
"name": "崩坏星穹铁道", "name": "崩坏星穹铁道",
"url": "https://bbs.mihoyo.com/sr/" "url": "https://bbs.mihoyo.com/sr/",
"otherName":["sr","星铁","穹轨","崩坏星穹铁道"]
}, },
{ {
"id": "7", "id": "7",
"forumId": "57", "forumId": "57",
"name": "绝区零", "name": "绝区零",
"url": "https://bbs.mihoyo.com/zzz/" "url": "https://bbs.mihoyo.com/zzz/",
"otherName":["绝区零","zzz"]
} }
] ]

View File

@ -199,6 +199,7 @@ const boards = {
name: '崩坏星穹铁道', name: '崩坏星穹铁道',
actid: 'e202304121516551', actid: 'e202304121516551',
biz:'hkrpg_cn', biz:'hkrpg_cn',
osbiz: 'hkrpg_global',
url: "https://bbs.mihoyo.com/sr/", url: "https://bbs.mihoyo.com/sr/",
signUrl(data, type, api) { //预留方法方便后续迭代 signUrl(data, type, api) { //预留方法方便后续迭代
let dataUrl = {} let dataUrl = {}

View File

@ -56,9 +56,11 @@ export async function relpyPrivate(userId, msg) {
export async function replyMake(e, _msg, lenght) { export async function replyMake(e, _msg, lenght) {
let nickname = Bot.nickname; let nickname = Bot.nickname;
if (e.isGroup) { if (e.isGroup) {
let info = await Bot.getGroupMemberInfo(e.group_id, Bot.uin) if(Bot?.getGroupMemberInfo){
let info = await Bot?.getGroupMemberInfo(e.group_id, Bot.uin)
nickname = info.card || info.nickname nickname = info.card || info.nickname
} }
}
let msgList = []; let msgList = [];
for (let [index, item] of Object.entries(_msg)) { for (let [index, item] of Object.entries(_msg)) {
if (index < lenght) { if (index < lenght) {
@ -118,9 +120,9 @@ export async function getCookieMap(cookie) {
*/ */
export function recallMsg(e,r,times){ export function recallMsg(e,r,times){
setTimeout(()=>{ setTimeout(()=>{
if(e?.group){ if(e?.group?.recallMsg){
e?.group?.recallMsg(r.message_id) e?.group?.recallMsg(r.message_id)
}else{ }else if(e?.friend?.recallMsg){
e?.friend?.recallMsg(r.message_id) e?.friend?.recallMsg(r.message_id)
} }
},1000 * times) },1000 * times)

View File

@ -155,7 +155,7 @@ export default class user {
`${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到\n`; `${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到\n`;
} }
} else { } else {
if (this.allSign ) { if (this.allSign) {
this.allSign[forum.name].error++; this.allSign[forum.name].error++;
} }
signMsg = `${item.nickname}-${item.game_uid}:验证码失败~\n` signMsg = `${item.nickname}-${item.game_uid}:验证码失败~\n`
@ -391,7 +391,7 @@ export default class user {
let msg = e?.msg; let msg = e?.msg;
//暂时先这样吧,等有空再优化~ //暂时先这样吧,等有空再优化~
this.allSign = { this.allSign = {
findModel: ["崩坏3", "崩坏2", '原神', '未定事件簿'], findModel: ["崩坏3", "崩坏2", '原神', '未定事件簿', '崩坏星穹铁道'],
"崩坏3": { "崩坏3": {
bindGame: 0, bindGame: 0,
sign: 0, sign: 0,
@ -475,7 +475,7 @@ export default class user {
let mul = e; let mul = e;
Bot.logger.mark(`云原神签到任务开始`); Bot.logger.mark(`云原神签到任务开始`);
let files = fs.readdirSync(this.yunPath).filter(file => file.endsWith('.yaml')) let files = fs.readdirSync(this.yunPath).filter(file => file.endsWith('.yaml'))
if(files.length==0) return; if (files.length == 0) return;
let isCloudSignMsg = this.configSign.isCloudSignMsg let isCloudSignMsg = this.configSign.isCloudSignMsg
let userIdList = (files.join(",").replace(/.yaml/g, "").split(",")) let userIdList = (files.join(",").replace(/.yaml/g, "").split(","))
if (cloudTask) { if (cloudTask) {
@ -617,7 +617,7 @@ export default class user {
bbsTask = false; bbsTask = false;
} }
async bbsGeetest() { async bbsGeetest() {
if(!this.getToken) return "" if (!this.getToken) return ""
try { try {
let res = await this.getData('bbsGetCaptcha', false) let res = await this.getData('bbsGetCaptcha', false)
// let challenge = res.data["challenge"] // let challenge = res.data["challenge"]
@ -636,7 +636,7 @@ export default class user {
return "" return ""
} }
async geetest(data) { async geetest(data) {
if(!this.getToken) return "" if (!this.getToken) return ""
try { try {
data.getToken = this.getToken data.getToken = this.getToken
let res = await this.getData("validate", data, false) let res = await this.getData("validate", data, false)
@ -788,16 +788,20 @@ export default class user {
res = await this.getData('getLtoken', { cookies: this.cookies }, false) res = await this.getData('getLtoken', { cookies: this.cookies }, false)
v2Sk = await this.getData('getByStokenV2', { headers: { Cookie: this.cookies } }, false) v2Sk = await this.getData('getByStokenV2', { headers: { Cookie: this.cookies } }, false)
} }
res = await this.getData("userGameInfo", this.ForumData[1], false) let list = []
if (res?.retcode != 0) { for (let item of ['崩坏星穹铁道', '原神']) {
return false; let result = await this.getData("userGameInfo",this.getDataList(item)[0], false)
if (result?.retcode != 0) {
continue;
} }
// console.log(res,this.e.sk) list.push(...result?.data?.list)
}
if(list.length==0) return false;
let uids = [] let uids = []
for (let s of res.data.list) { for (let s of list) {
let datalist = {} let datalist = {}
let uid = s.game_uid let uid = s.game_uid
uids.push(uid) uids.push(s.region_name+':'+uid)
datalist[uid] = { datalist[uid] = {
stuid: this.e?.sk?.get('stuid') || this.e.stuid, stuid: this.e?.sk?.get('stuid') || this.e.stuid,
stoken: v2Sk?.data?.token?.token || this.e?.sk?.get('stoken') || data?.data?.list[0].token, stoken: v2Sk?.data?.token?.token || this.e?.sk?.get('stoken') || data?.data?.list[0].token,
@ -805,11 +809,13 @@ export default class user {
mid: this.e?.sk?.get('mid') || v2Sk?.data?.user_info?.mid, mid: this.e?.sk?.get('mid') || v2Sk?.data?.user_info?.mid,
uid: uid, uid: uid,
userId: this.e.user_id, userId: this.e.user_id,
is_sign: true is_sign: true,
region_name:s.region_name,
region:s.region
} }
await gsCfg.saveBingStoken(this.e.user_id, datalist) await gsCfg.saveBingStoken(this.e.user_id, datalist)
} }
let msg = `uid:${uids.join(',')}\nstoken绑定成功您可通过下列指令进行操作:`; let msg = `${uids.join('\n')}\nstoken绑定成功您可通过下列指令进行操作:`;
msg += '\n【#米币查询】查询米游币余额' msg += '\n【#米币查询】查询米游币余额'
msg += '\n【#mys原神签到】获取米游币' msg += '\n【#mys原神签到】获取米游币'
msg += '\n【#更新抽卡记录】更新抽卡记录' msg += '\n【#更新抽卡记录】更新抽卡记录'
@ -851,9 +857,10 @@ export default class user {
}) })
} }
getDataList(name) { getDataList(name) {
for (let item of this.ForumData) { let otherName = lodash.map(this.ForumData,'otherName')
if (item.name == name) { //循环结束未找到的时候返回原数组签到全部 for (let [index,item] of Object.entries(otherName)) {
return [item] if (item.includes(name)) { //循环结束未找到的时候返回原数组签到全部
return [this.ForumData[index]]
} }
} }
return this.ForumData; return this.ForumData;