mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-22 19:10:53 +08:00
格式化部分内容
This commit is contained in:
parent
9ab7a3f5dd
commit
4db9fdf24e
@ -120,10 +120,10 @@ export async function getCookieMap(cookie) {
|
||||
*/
|
||||
export function recallMsg(e,r,times){
|
||||
setTimeout(()=>{
|
||||
if(e?.group?.recallMsg){
|
||||
e?.group?.recallMsg(r.message_id)
|
||||
}else if(e?.friend?.recallMsg){
|
||||
e?.friend?.recallMsg(r.message_id)
|
||||
if(e?.group?.recallMsg&&r?.message_id){
|
||||
e?.group?.recallMsg(r?.message_id)
|
||||
}else if(e?.friend?.recallMsg&&r?.message_id){
|
||||
e?.friend?.recallMsg(r?.message_id)
|
||||
}
|
||||
},1000 * times)
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
Data
|
||||
} from "../components/index.js";
|
||||
import moment from 'moment'
|
||||
|
||||
const _path = process.cwd();
|
||||
const plugin = "xiaoyao-cvs-plugin"
|
||||
const nameData = ["原神", "崩坏3", "崩坏2", "未定事件簿"];
|
||||
@ -72,6 +73,7 @@ export default class user {
|
||||
}
|
||||
return sumData;
|
||||
}
|
||||
|
||||
async getData(type, data = {}, isck = true) {
|
||||
if (isck) {
|
||||
await this.cookie(this.e)
|
||||
@ -195,9 +197,11 @@ export default class user {
|
||||
upData
|
||||
}
|
||||
}
|
||||
|
||||
async docHelp(type) {
|
||||
return this.configSign[type.includes("云") ? "cloudDoc" : "cookiesDoc"]
|
||||
}
|
||||
|
||||
async cloudSign() {
|
||||
await this.cloudSeach()
|
||||
let res = await this.getData("cloudReward")
|
||||
@ -220,6 +224,7 @@ export default class user {
|
||||
Bot.logger.mark(`\n云原神签到用户:${this.e.user_id}:${res.message}\n`)
|
||||
return res
|
||||
}
|
||||
|
||||
async cloudSeach() {
|
||||
let res = await this.getData("cloudGet")
|
||||
if (res?.retcode == -100) {
|
||||
@ -234,6 +239,7 @@ export default class user {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
async bbsSeachSign() {
|
||||
let res = await this.getData("bbsisSign", {
|
||||
name: "原神"
|
||||
@ -248,6 +254,7 @@ export default class user {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
async getbbsSign(forumData) {
|
||||
let message = '',
|
||||
challenge = '',
|
||||
@ -353,6 +360,7 @@ export default class user {
|
||||
message
|
||||
}
|
||||
}
|
||||
|
||||
async signTask(e = "") {
|
||||
let mul = e;
|
||||
//暂不支持多个uid签到
|
||||
@ -471,6 +479,7 @@ export default class user {
|
||||
}
|
||||
mysTask = false;
|
||||
}
|
||||
|
||||
async cloudTask(e = "") {
|
||||
let mul = e;
|
||||
Bot.logger.mark(`云原神签到任务开始`);
|
||||
@ -531,6 +540,7 @@ export default class user {
|
||||
}
|
||||
cloudTask = false;
|
||||
}
|
||||
|
||||
countTime(time) {
|
||||
let hour = Math.floor((time / 3600) % 24)
|
||||
let min = Math.floor((time / 60) % 60)
|
||||
@ -541,6 +551,7 @@ export default class user {
|
||||
if (sec > 0) msg += `${sec}秒`
|
||||
return msg
|
||||
}
|
||||
|
||||
async bbsTask(e = "") {
|
||||
let mul = e;
|
||||
Bot.logger.mark(`开始米社米币签到任务`);
|
||||
@ -616,6 +627,7 @@ export default class user {
|
||||
}
|
||||
bbsTask = false;
|
||||
}
|
||||
|
||||
async bbsGeetest() {
|
||||
if (!this.getToken) return ""
|
||||
try {
|
||||
@ -635,6 +647,7 @@ export default class user {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
async geetest(data) {
|
||||
if (!this.getToken) return ""
|
||||
try {
|
||||
@ -651,6 +664,7 @@ export default class user {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
getyunToken(e) {
|
||||
let file = `${this.yunPath}${e.user_id}.yaml`
|
||||
try {
|
||||
@ -663,6 +677,7 @@ export default class user {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
async cookie(e) {
|
||||
let {
|
||||
cookie,
|
||||
@ -687,20 +702,22 @@ export default class user {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async getcookiesDoc() {
|
||||
return await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").cookiesDoc
|
||||
}
|
||||
|
||||
async getCookie(e) {
|
||||
let skuid, cookie, uid
|
||||
if (isV3) {
|
||||
skuid = await gsCfg.getBingCookie(e.user_id);
|
||||
cookie = skuid?.ck;
|
||||
uid = skuid?.item;
|
||||
if(!uid){ //获取uid为空时进行后续处理获取 (临时处理方式后续会进行解耦以避免这种情况。。待咕中.)s
|
||||
uid=e.user.mainUid[e.isSr?'sr':'gs'] //由于目前只支持原神功能暂时先写死
|
||||
lodash.mapValues(e.user.mysUsers, function(o) {
|
||||
if(o.uids[e.isSr?'sr':'gs'].includes(uid)){
|
||||
cookie=o.ck
|
||||
if (!uid && e.user) { //获取uid为空时进行后续处理获取 (临时处理方式后续会进行解耦以避免这种情况。。待咕中.)s
|
||||
uid = e.user?.mainUid[e.isSr ? 'sr' : 'gs'] //由于目前只支持原神功能暂时先写死
|
||||
lodash.mapValues(e.user.mysUsers, function (o) {
|
||||
if (o.uids[e.isSr ? 'sr' : 'gs'].includes(uid)) {
|
||||
cookie = o.ck
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -726,6 +743,7 @@ export default class user {
|
||||
skuid
|
||||
}
|
||||
}
|
||||
|
||||
async stoken(cookie, e) {
|
||||
this.e = e;
|
||||
let datalist = this.getStoken(e.user_id) || {}
|
||||
@ -756,6 +774,7 @@ export default class user {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
getStoken(userId) {
|
||||
let file = `${yamlDataUrl}/${userId}.yaml`
|
||||
try {
|
||||
@ -773,16 +792,17 @@ export default class user {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
async seachUid(data) {
|
||||
let ltoken = '', v2Sk;
|
||||
if (data?.data) {
|
||||
let res;
|
||||
if (this.e.sk) {
|
||||
if (this.e.sk.get('stoken').includes('v2_')) {
|
||||
res = await this.getData('getLtoken', { cookies: this.e.raw_message }, false)
|
||||
res = await this.getData('getLtoken', {cookies: this.e.raw_message}, false)
|
||||
ltoken = res?.data?.ltoken
|
||||
} else {
|
||||
v2Sk = await this.getData('getByStokenV2', { headers: { Cookie: this.e.raw_message } }, false)
|
||||
v2Sk = await this.getData('getByStokenV2', {headers: {Cookie: this.e.raw_message}}, false)
|
||||
}
|
||||
this.e.cookie =
|
||||
`ltoken=${this.e.sk?.get('ltoken') || ltoken};ltuid=${this.e.sk?.get('stuid')};cookie_token=${data.data.cookie_token}; account_id=${this.e.sk?.get('stuid')};`
|
||||
@ -793,23 +813,23 @@ export default class user {
|
||||
} else {
|
||||
this.e.cookie = this.e.original_msg //发送的为cookies
|
||||
this.cookies = `stuid=${this.e.stuid};stoken=${data?.data?.list[0].token};ltoken=${data?.data?.list[1].token}`
|
||||
res = await this.getData('getLtoken', { cookies: this.cookies }, false)
|
||||
v2Sk = await this.getData('getByStokenV2', { headers: { Cookie: this.cookies } }, false)
|
||||
res = await this.getData('getLtoken', {cookies: this.cookies}, false)
|
||||
v2Sk = await this.getData('getByStokenV2', {headers: {Cookie: this.cookies}}, false)
|
||||
}
|
||||
let list = []
|
||||
for (let item of ['崩坏星穹铁道', '原神']) {
|
||||
let result = await this.getData("userGameInfo",this.getDataList(item)[0], false)
|
||||
let result = await this.getData("userGameInfo", this.getDataList(item)[0], false)
|
||||
if (result?.retcode != 0) {
|
||||
continue;
|
||||
}
|
||||
list.push(...result?.data?.list)
|
||||
}
|
||||
if(list.length==0) return false;
|
||||
if (list.length == 0) return false;
|
||||
let uids = []
|
||||
for (let s of list) {
|
||||
let datalist = {}
|
||||
let uid = s.game_uid
|
||||
uids.push(s.region_name+':'+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,
|
||||
@ -818,8 +838,8 @@ export default class user {
|
||||
uid: uid,
|
||||
userId: this.e.user_id,
|
||||
is_sign: true,
|
||||
region_name:s.region_name,
|
||||
region:s.region
|
||||
region_name: s.region_name,
|
||||
region: s.region
|
||||
}
|
||||
await gsCfg.saveBingStoken(this.e.user_id, datalist)
|
||||
}
|
||||
@ -864,9 +884,10 @@ export default class user {
|
||||
return true;
|
||||
})
|
||||
}
|
||||
|
||||
getDataList(name) {
|
||||
let otherName = lodash.map(this.ForumData,'otherName')
|
||||
for (let [index,item] of Object.entries(otherName)) {
|
||||
let otherName = lodash.map(this.ForumData, 'otherName')
|
||||
for (let [index, item] of Object.entries(otherName)) {
|
||||
if (item.includes(name)) { //循环结束未找到的时候返回原数组签到全部
|
||||
return [this.ForumData[index]]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user