From a389028b57b6da6596986af10d81a754dc7c1987 Mon Sep 17 00:00:00 2001 From: Ctrlcvs <1509167646@qq.com> Date: Fri, 5 May 2023 13:32:31 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=AD=A3sk=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E6=98=9F=E7=A9=B9=E9=93=81=E9=81=93=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98=EF=BC=88#81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/mys/mysTool.js | 1 + model/user.js | 32 +++++++++++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/model/mys/mysTool.js b/model/mys/mysTool.js index 1be7401..5073458 100644 --- a/model/mys/mysTool.js +++ b/model/mys/mysTool.js @@ -199,6 +199,7 @@ const boards = { name: '崩坏星穹铁道', actid: 'e202304121516551', biz:'hkrpg_cn', + osbiz: 'hkrpg_global', url: "https://bbs.mihoyo.com/sr/", signUrl(data, type, api) { //预留方法方便后续迭代 let dataUrl = {} diff --git a/model/user.js b/model/user.js index 4bf2ecc..9e90d1b 100644 --- a/model/user.js +++ b/model/user.js @@ -155,7 +155,7 @@ export default class user { `${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到\n`; } } else { - if (this.allSign ) { + if (this.allSign) { this.allSign[forum.name].error++; } signMsg = `${item.nickname}-${item.game_uid}:验证码失败~\n` @@ -391,7 +391,7 @@ export default class user { let msg = e?.msg; //暂时先这样吧,等有空再优化~ this.allSign = { - findModel: ["崩坏3", "崩坏2", '原神', '未定事件簿'], + findModel: ["崩坏3", "崩坏2", '原神', '未定事件簿', '崩坏星穹铁道'], "崩坏3": { bindGame: 0, sign: 0, @@ -475,7 +475,7 @@ export default class user { let mul = e; Bot.logger.mark(`云原神签到任务开始`); 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 userIdList = (files.join(",").replace(/.yaml/g, "").split(",")) if (cloudTask) { @@ -617,7 +617,7 @@ export default class user { bbsTask = false; } async bbsGeetest() { - if(!this.getToken) return "" + if (!this.getToken) return "" try { let res = await this.getData('bbsGetCaptcha', false) // let challenge = res.data["challenge"] @@ -636,7 +636,7 @@ export default class user { return "" } async geetest(data) { - if(!this.getToken) return "" + if (!this.getToken) return "" try { data.getToken = this.getToken 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) v2Sk = await this.getData('getByStokenV2', { headers: { Cookie: this.cookies } }, false) } - res = await this.getData("userGameInfo", this.ForumData[1], false) - if (res?.retcode != 0) { - return false; + let list = [] + for (let item of ['崩坏星穹铁道', '原神']) { + let result = await this.getData("userGameInfo",this.getDataList(item)[0], false) + if (result?.retcode != 0) { + continue; + } + list.push(...result?.data?.list) } - // console.log(res,this.e.sk) + if(list.length==0) return false; let uids = [] - for (let s of res.data.list) { + for (let s of list) { let datalist = {} let uid = s.game_uid - uids.push(uid) + uids.push(s.region_name+':'+uid) datalist[uid] = { stuid: this.e?.sk?.get('stuid') || this.e.stuid, 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, uid: uid, 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) } - let msg = `uid:${uids.join(',')}\nstoken绑定成功您可通过下列指令进行操作:`; + let msg = `${uids.join('\n')}\nstoken绑定成功您可通过下列指令进行操作:`; msg += '\n【#米币查询】查询米游币余额' msg += '\n【#mys原神签到】获取米游币' msg += '\n【#更新抽卡记录】更新抽卡记录' From d2e32faa08167087cd3a82a016239c29df854d7d Mon Sep 17 00:00:00 2001 From: Ctrlcvs <1509167646@qq.com> Date: Sun, 7 May 2023 18:36:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=AD=BE=E5=88=B0?= =?UTF-8?q?=E6=8C=87=E4=BB=A4=E5=88=AB=E5=90=8D=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E8=A1=A5=E5=85=85`=E6=B8=B8=E6=88=8F=E7=AD=BE=E5=88=B0`?= =?UTF-8?q?=E6=8C=87=E4=BB=A4=EF=BC=8C=E6=94=AF=E6=8C=81=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E7=BB=91=E5=AE=9A=E7=9A=84=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E6=A8=A1=E5=9D=97=E7=AD=BE=E5=88=B0=EF=BC=88?= =?UTF-8?q?=E9=9C=80=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=9C=89=E7=9A=84?= =?UTF-8?q?=E6=A8=A1=E5=9D=97~=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/sign.js | 8 +++++++- defSet/json/mys.json | 21 ++++++++++++++------- model/mys/utils.js | 4 ++-- model/user.js | 7 ++++--- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/apps/sign.js b/apps/sign.js index 8e8cd03..9b8156e 100644 --- a/apps/sign.js +++ b/apps/sign.js @@ -1,8 +1,14 @@ import User from "../model/user.js" 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 = { sign: { - reg: `^#*(原神|崩坏3|崩坏2|未定事件簿|崩坏星穹铁道)签到$`, + reg: `^#*(${lodash.map(ForumData,v=> v.otherName.join('|')).join('|')}|游戏)签到$`, describe: "米社规则签到" }, bbsSign: { diff --git a/defSet/json/mys.json b/defSet/json/mys.json index 0981448..4842d6f 100644 --- a/defSet/json/mys.json +++ b/defSet/json/mys.json @@ -3,42 +3,49 @@ "id": "1", "forumId": "1", "name": "崩坏3", - "url": "https://bbs.mihoyo.com/bh3/" + "url": "https://bbs.mihoyo.com/bh3/", + "otherName":["bh3","崩崩崩","崩坏2"] }, { "id": "2", "forumId": "26", "name": "原神", - "url": "https://bbs.mihoyo.com/ys/" + "url": "https://bbs.mihoyo.com/ys/", + "otherName":["原神"] }, { "id": "3", "forumId": "30", "name": "崩坏2", - "url": "https://bbs.mihoyo.com/bh2/" + "url": "https://bbs.mihoyo.com/bh2/", + "otherName":["bh2","崩崩","崩坏2"] }, { "id": "4", "forumId": "37", "name": "未定事件簿", - "url": "https://bbs.mihoyo.com/wd/" + "url": "https://bbs.mihoyo.com/wd/", + "otherName":["事件簿","未定事件簿"] }, { "id": "5", "forumId": "34", "name": "大别野", - "url": "https://bbs.mihoyo.com/dby/" + "url": "https://bbs.mihoyo.com/dby/", + "otherName":["大别野"] }, { "id": "6", "forumId": "52", "name": "崩坏星穹铁道", - "url": "https://bbs.mihoyo.com/sr/" + "url": "https://bbs.mihoyo.com/sr/", + "otherName":["sr","星铁","穹轨","崩坏星穹铁道"] }, { "id": "7", "forumId": "57", "name": "绝区零", - "url": "https://bbs.mihoyo.com/zzz/" + "url": "https://bbs.mihoyo.com/zzz/", + "otherName":["绝区零","zzz"] } ] \ No newline at end of file diff --git a/model/mys/utils.js b/model/mys/utils.js index aefd42e..d3c0ee0 100644 --- a/model/mys/utils.js +++ b/model/mys/utils.js @@ -118,9 +118,9 @@ export async function getCookieMap(cookie) { */ export function recallMsg(e,r,times){ setTimeout(()=>{ - if(e?.group){ + if(e?.group?.recallMsg){ e?.group?.recallMsg(r.message_id) - }else{ + }else if(e?.friend?.recallMsg){ e?.friend?.recallMsg(r.message_id) } },1000 * times) diff --git a/model/user.js b/model/user.js index 9e90d1b..f239463 100644 --- a/model/user.js +++ b/model/user.js @@ -857,9 +857,10 @@ export default class user { }) } getDataList(name) { - for (let item of this.ForumData) { - if (item.name == name) { //循环结束未找到的时候返回原数组签到全部 - return [item] + let otherName = lodash.map(this.ForumData,'otherName') + for (let [index,item] of Object.entries(otherName)) { + if (item.includes(name)) { //循环结束未找到的时候返回原数组签到全部 + return [this.ForumData[index]] } } return this.ForumData; From 1d15af86ad58107056ea024a6944d28bbcecb7ec Mon Sep 17 00:00:00 2001 From: Ctrlcvs <1509167646@qq.com> Date: Wed, 10 May 2023 09:35:20 +0800 Subject: [PATCH 3/3] fix --- defSet/json/mys.json | 4 ++-- model/mys/utils.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/defSet/json/mys.json b/defSet/json/mys.json index 4842d6f..997f983 100644 --- a/defSet/json/mys.json +++ b/defSet/json/mys.json @@ -4,7 +4,7 @@ "forumId": "1", "name": "崩坏3", "url": "https://bbs.mihoyo.com/bh3/", - "otherName":["bh3","崩崩崩","崩坏2"] + "otherName":["bh3","崩崩崩","崩坏3"] }, { "id": "2", @@ -25,7 +25,7 @@ "forumId": "37", "name": "未定事件簿", "url": "https://bbs.mihoyo.com/wd/", - "otherName":["事件簿","未定事件簿"] + "otherName":["事件簿","未定事件簿","未定"] }, { "id": "5", diff --git a/model/mys/utils.js b/model/mys/utils.js index d3c0ee0..6849ff4 100644 --- a/model/mys/utils.js +++ b/model/mys/utils.js @@ -56,8 +56,10 @@ export async function relpyPrivate(userId, msg) { export async function replyMake(e, _msg, lenght) { let nickname = Bot.nickname; if (e.isGroup) { - let info = await Bot.getGroupMemberInfo(e.group_id, Bot.uin) - nickname = info.card || info.nickname + if(Bot?.getGroupMemberInfo){ + let info = await Bot?.getGroupMemberInfo(e.group_id, Bot.uin) + nickname = info.card || info.nickname + } } let msgList = []; for (let [index, item] of Object.entries(_msg)) {