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 2023-01-14 11:08:36 +08:00
parent 609d2ceb7e
commit bc7ad7b40e
4 changed files with 69 additions and 66 deletions

View File

@ -28,29 +28,29 @@ function init() {
export async function Note(e, {
render
}, poke) {
if (!Cfg.get("sys.Note") && !poke) {
if (!Cfg.get("sys.Note") && !poke && !this.e?.isTask) {
return false;
}
let notes = new note(e);
let cookie, uid, res;
if (isV3) {
if(e.msg.replace(/全|全部/g,'多').includes('多')){
let ck=await gsCfg.getBingCkSingle(e.user_id)
if(Object.keys(ck).length==0){
if (e.msg.replace(/全|全部/g, '多').includes('多')) {
let ck = await gsCfg.getBingCkSingle(e.user_id)
if (Object.keys(ck).length == 0) {
e.reply(`请先【#绑定cookie】`)
return true;
}
let sendMsg=[]
e._reply=e.reply;
e.reply=((msg)=>{
let sendMsg = []
e._reply = e.reply;
e.reply = ((msg) => {
sendMsg.push(msg)
})
if(Object.keys(ck).length>1){
if (Object.keys(ck).length > 1) {
e._reply(`多账号体力查询中请稍等...`)
}
for(let item of Object.keys(ck)){
let res=await (await e.runtime.createMysApi(ck[item].uid,ck[item].ck)).getData('dailyNote')
await notes.getNote(ck[item].ck,ck[item].uid,res,{render})
for (let item of Object.keys(ck)) {
let res = await (await e.runtime.createMysApi(ck[item].uid, ck[item].ck)).getData('dailyNote')
await notes.getNote(ck[item].ck, ck[item].uid, res, { render })
}
e._reply(sendMsg)
return true;
@ -99,22 +99,22 @@ export async function Note(e, {
e.reply(`体力查询错误:${res.message}`);
Bot.logger.mark(`体力查询错误:${JSON.stringify(res)}`);
}
return true;
}
//redis保存uid
redis.set(`genshin:uid:${e.user_id}`, uid, {
EX: 2592000
});
//更新
if (NoteCookie[e.user_id]) {
NoteCookie[e.user_id].maxTime = new Date().getTime() + res.data.resin_recovery_time * 1000;
saveJson();
}
}
return await notes.getNote(cookie,uid,res,{render})
return await notes.getNote(cookie, uid, res, { render })
}
async function getDailyNote(uid, cookie) {
@ -226,7 +226,7 @@ export async function pokeNote(e, {
export async function Note_appoint(e) {
let mbPath = `${_path}/plugins/xiaoyao-cvs-plugin/resources/dailyNote/`;
let isDel= e.msg.includes("移除")
let isDel = e.msg.includes("移除")
let msg = e.msg.replace(/#|井|体力|模板|设置|移除/g, "");
let All = ["默认", "随机", "0"];
let urlType = note_file();
@ -242,7 +242,7 @@ export async function Note_appoint(e) {
if (msg.includes("列表")) {
let isUser = msg.includes('我的')
let temp = tempData[e.user_id]?.temp;
if ((!temp||temp?.length===0) && isUser) {
if ((!temp || temp?.length === 0) && isUser) {
e.reply("未获取到您设置的模板信息哦~")
return true;
}
@ -316,16 +316,16 @@ export async function Note_appoint(e) {
if (typeof tempData[e.user_id]["temp"] === "string") {
temp = [tempData[e.user_id]["temp"], msg]
} else {
temp =tempData[e.user_id]["temp"]
temp = tempData[e.user_id]["temp"]
if (!tempData[e.user_id]["temp"]?.includes(msg)) {
temp.push(msg)
}
}
let sendMsg="诶~这是你选的模板吗,模板设置成功了快用指令来试试吧~"
if(isDel){
if(temp.includes(msg)){
temp.splice(temp.indexOf(msg),1)
sendMsg=`模板${msg}已移除~`
let sendMsg = "诶~这是你选的模板吗,模板设置成功了快用指令来试试吧~"
if (isDel) {
if (temp.includes(msg)) {
temp.splice(temp.indexOf(msg), 1)
sendMsg = `模板${msg}已移除~`
}
}
tempData[e.user_id] = {
@ -338,7 +338,7 @@ export async function Note_appoint(e) {
return true;
}
const note_file = function(xiaoyao) {
const note_file = function (xiaoyao) {
let url1 = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/Template/`
let url2 = `./plugins/xiaoyao-cvs-plugin/resources/BJT-Templet/` //冤种情况。。
let url3 = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/background_image/`

View File

@ -5,7 +5,7 @@ import {
} from '../components/Changelog.js'
import utils from './mys/utils.js';
import gsCfg from './gsCfg.js';
import {segment} from 'oicq'
import { segment } from 'oicq'
export default class mysTopLogin {
constructor(e) {
this.e = e;
@ -64,7 +64,7 @@ export default class mysTopLogin {
this.e.reply(`请将账号密码用逗号隔开发送以完成绑定\n账号xxx@qq.com,密码xxxxx`)
}
async UserPassLogin() {
let msg = this.e.msg.replace(/账号|密码||:/g,'').replace(/,|/, ',').split(',');
let msg = this.e.msg.replace(/账号|密码||:/g, '').replace(/,|/, ',').split(',');
if (msg.length != 2) {
return false;
}
@ -77,7 +77,7 @@ export default class mysTopLogin {
Bot.logger.mark("[米哈游登录] 正在验证")
this.aigis_captcha_data = JSON.parse(res.aigis_data.data)
// let validate = await this.crack_geetest()
let validate = await this.user.getData("validate",this.aigis_captcha_data,false)
let validate = await this.user.getData("validate", this.aigis_captcha_data, false)
if (validate?.data?.validate) {
Bot.logger.mark("[米哈游登录] 验证成功")
} else {
@ -85,25 +85,25 @@ export default class mysTopLogin {
this.e.reply('接口效验失败,请重新尝试~')
return false
}
let aigis= res.aigis_data.session_id + ";" + Buffer.from(JSON.stringify({
let aigis = res.aigis_data.session_id + ";" + Buffer.from(JSON.stringify({
geetest_challenge: validate?.data?.challenge,
geetest_seccode: validate?.data?.validate + "|jordan",
geetest_validate: validate?.data?.validate
})).toString("base64")
body.headers={
'x-rpc-aigis':aigis,
body.headers = {
'x-rpc-aigis': aigis,
}
res = await this.user.getData("loginByPassword",body,false)
res = await this.user.getData("loginByPassword", body, false)
Bot.logger.mark(`[米哈游登录] ${Bot.logger.blue(JSON.stringify(res))}`)
}
if (res.retcode == 0) {
let cookies=`stoken=${res.data.token.token}&mid=${res.data.user_info.mid}`
let cookie_token =this.user.getData("bbsGetCookie",{cookies})
let cookies = `stoken=${res.data.token.token}&mid=${res.data.user_info.mid}`
let cookie_token = this.user.getData("bbsGetCookie", { cookies })
let ltoken = await this.user.getData('getLtoken', { cookies: `${cookies};stuid=${res.data.user_info.aid};` }, false)
Bot.logger.mark(`[米哈游登录] ${Bot.logger.blue(JSON.stringify(cookie_token))}`)
return {
cookie:`ltoken=${ltoken?.data?.ltoken};ltuid=${res.data.user_info.aid};cookie_token=${cookie_token?.data?.cookie_token};`,
stoken:`${cookies};stuid=${res.data.user_info.aid};`
cookie: `ltoken=${ltoken?.data?.ltoken};ltuid=${res.data.user_info.aid};cookie_token=${cookie_token?.data?.cookie_token};`,
stoken: `${cookies};stuid=${res.data.user_info.aid};`
}
} else {
await this.e.reply(`错误:${JSON.stringify(res)}`, true)
@ -111,13 +111,13 @@ export default class mysTopLogin {
}
}
async crack_geetest() {
let res =await this.user.getData("microgg", this.aigis_captcha_data, false)
let res = await this.user.getData("microgg", this.aigis_captcha_data, false)
Bot.logger.mark(`[米哈游登录] ${Bot.logger.blue(JSON.stringify(res))}`)
await this.e.reply(`请完成验证:${res.shorturl}`, true)
for (let n = 1; n < 60; n++) {
await utils.sleepAsync(5000)
try {
res =await this.user.getData("microggVl", this.aigis_captcha_data, false)
res = await this.user.getData("microggVl", this.aigis_captcha_data, false)
if (res.geetest_validate) {
return res
}
@ -129,12 +129,12 @@ export default class mysTopLogin {
return false;
}
async showgoods(){
async showgoods() {
let goodslist = await this.goodsList()
if(!goodslist) return false;
if (!goodslist) return false;
let msg = ['当前支持的商品有:\n']
for (const [i, goods] of Object.entries(goodslist)) {
if(i=='api') continue;
if (i == 'api') continue;
let num = `${goods['goods_name']}×${(goods['goods_unit'])}` + ((goods['goods_unit']) > 0 ? goods["goods_name"] : '')
// console.log(`ID${i} ${num} 价格:${parseInt(goods['price']) / 100}元`)
msg.push(`ID${i} ${num} 价格:${parseInt(goods['price']) / 100}\n`)
@ -143,7 +143,7 @@ export default class mysTopLogin {
return true;
}
async GetCode(){
async GetCode() {
try {
let msg = this.e.msg.replace(/,||\|/g, ' ').split(' ')
if (msg.length != 3) {
@ -155,12 +155,12 @@ export default class mysTopLogin {
this.e.reply('uid格式不对!')
return true;
}
let res =await this.user.getData('GetCode',{msg:this.e.msg.replace('#','')})
if(!res) return false;
if(res?.code!=200&&res?.retcode!=0){
let res = await this.user.getData('GetCode', { msg: this.e.msg.replace('#', '') })
if (!res) return false;
if (res?.code != 200 && res?.retcode != 0) {
return true
}
this.e.reply([`uid:${res.data.uid},请使用${iswx=='weixin'?'微信':"支付宝"}扫码支付:`,segment.image(res.data.base64.replace("data:image/png;base64,", "base64://")),`\n订单号:${res['data']['order_no']}\n 价格:${(res['data']['amount'])/100}`])
this.e.reply([`uid:${res.data.uid},请使用${iswx == 'weixin' ? '微信' : "支付宝"}扫码支付:`, segment.image(res.data.base64.replace("data:image/png;base64,", "base64://")), `\n订单号:${res['data']['order_no']}\n 价格:${(res['data']['amount']) / 100}`])
} catch (error) {
this.e.reply('出问题了捏')
}
@ -168,28 +168,28 @@ export default class mysTopLogin {
}
async goodsList() {
let goods =await this.user.getData("goodsList")
if(!goods) return false;
let goods = await this.user.getData("goodsList")
if (!goods) return false;
return goods;
}
async checkOrder(){
let msg,uid,order_no
if(!this.e.source){
msg=this.e.msg.match(/\d{9,}/g)
uid=msg[0],order_no=msg[1]
}else{
msg=this.e.source.message.match(/\d{9,}/g)
uid=msg[0],order_no=msg[1]
async checkOrder() {
let msg, uid, order_no
if (!this.e.source) {
msg = this.e.msg.match(/\d{9,}/g)
uid = msg[0], order_no = msg[1]
} else {
msg = this.e.source.message.match(/\d{9,}/g)
uid = msg[0], order_no = msg[1]
}
let res=await this.user.getData('checkOrder',{
uid,order_no
},false)
if(!res) return false;
if(res?.data?.status==1){
let res = await this.user.getData('checkOrder', {
uid, order_no
}, false)
if (!res) return false;
if (res?.data?.status == 1) {
this.e.reply(`uid:${uid},订单:${order_no}等待支付中`)
}else if(res?.data?.status==999){
} else if (res?.data?.status == 999) {
this.e.reply(`uid:${uid},订单:${order_no}已支付完成`)
}else{
} else {
this.e.reply(`订单:${order_no},${res.message}`)
}
return true

View File

@ -114,7 +114,7 @@ export function recallMsg(e,r,times){
if(e.group){
e.group.recallMsg(r.message_id)
}else{
e.member.recallMsg(r.message_id)
e.friend.recallMsg(r.message_id)
}
},1000 * times)
}

View File

@ -8,18 +8,21 @@
background-color: rgb(243, 242, 241);
padding: 20px 0 10px 0 !important;
}
.topTitle table{
margin: 0 auto;
}
</style>
{{/block}}
{{block 'main'}}
<div class="topTitle">
<div class="topTitle" style="margin: 0 auth;">
</div>
<script src="{{_res_path}}/qrCode/js/jquery-1.10.2.min.js"></script>
<script src="{{_res_path}}/qrCode/js/jquery.qrcode.min.js"></script>
<script>
var config = {
width:600,//值是number类型, 表示的单位是px 必须传递
height:600,//值是number类型, 表示的单位是px 必须传递
width:500,//值是number类型, 表示的单位是px 必须传递
height:500,//值是number类型, 表示的单位是px 必须传递
text:"{{url}}".replace(/#38;/g,''),//text就表示二维码中存储的数据 必须传递
correctLevel:2,//取值为0|1|2|3 表示二维码的纠错级别0:L/1:M/2:Q/3:H ,默认0 可选参数
render:"table"//取值:table/canvas , 默认table 可选参数