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-01-14 07:27:13 +08:00
parent 16cea766be
commit 3bdc02c662
4 changed files with 111 additions and 17 deletions

View File

@ -45,13 +45,13 @@ import {
} from "./sign.js" } from "./sign.js"
import { import {
rule as topupLoginRule, rule as topupLoginRule,
qrCodeLogin,UserPassMsg,UserPassLogin, qrCodeLogin,UserPassMsg,UserPassLogin,GetCode,showgoods,checkOrder
} from './mhyTopUpLogin.js' } from './mhyTopUpLogin.js'
export { export {
updateRes, updateTemp, updateRes, updateTemp,
delSign, gcPaylog, delSign, gcPaylog,
cloudSign,qrCodeLogin, cloudSign,qrCodeLogin,
seach, bindLogin_ticket, seach, bindLogin_ticket,GetCode,showgoods,checkOrder,
bbsSign,UserPassMsg,UserPassLogin, bbsSign,UserPassMsg,UserPassLogin,
gclog, gclog,
mytoken, getBasicVoide, mytoken, getBasicVoide,

View File

@ -15,19 +15,36 @@ export const rule = {
describe: "账号密码登录" describe: "账号密码登录"
}, },
UserPassLogin: { UserPassLogin: {
reg: `^(.*)$`, reg: `^账号(.*)密码(.*)$`,
describe: "账号密码登录" describe: "账号密码登录"
}, },
// GetCode: { GetCode: {
// /** 命令正则匹配 */ /** 命令正则匹配 */
// reg: '^#?原神(微信)?充值(微信)?(.*)$', reg: '^#?原神(微信)?充值(微信)?(.*)$',
// /** 执行方法 */ /** 执行方法 */
// describe: '原神充值(离线)' describe: '原神充值(离线)'
// }, showgoods: { }, showgoods: {
// reg: "^#?商品列表", reg: "^#?商品列表",
// fnc: '原神充值商品列表' describe: '原神充值商品列表'
// } },checkOrder:{
reg:'^#?订单查询',
describe:'充值订单查询'
}
} }
export async function checkOrder(e) {
let Mys = new mys(e)
return await Mys.checkOrder()
}
export async function GetCode(e) {
let Mys = new mys(e)
return await Mys.GetCode()
}
export async function showgoods(e) {
let Mys = new mys(e)
return await Mys.showgoods()
}
export async function qrCodeLogin(e, { render }) { export async function qrCodeLogin(e, { render }) {
let Mys = new mys(e) let Mys = new mys(e)
@ -60,7 +77,7 @@ export async function UserPassLogin(e) {
let Mys = new mys(e) let Mys = new mys(e)
let res = await Mys.UserPassLogin(); let res = await Mys.UserPassLogin();
if (res) await bindSkCK(e, res) if (res) await bindSkCK(e, res)
return true; return res;
} }
export async function bindSkCK(e, res) { export async function bindSkCK(e, res) {

View File

@ -5,7 +5,7 @@ import {
} from '../components/Changelog.js' } from '../components/Changelog.js'
import utils from './mys/utils.js'; import utils from './mys/utils.js';
import gsCfg from './gsCfg.js'; import gsCfg from './gsCfg.js';
import {segment} from 'oicq'
export default class mysTopLogin { export default class mysTopLogin {
constructor(e) { constructor(e) {
this.e = e; this.e = e;
@ -61,10 +61,10 @@ export default class mysTopLogin {
async UserPassMsg() { async UserPassMsg() {
this.e.reply(this.sendMsgUserPassLogin) this.e.reply(this.sendMsgUserPassLogin)
this.e.reply(`请将账号密码用逗号隔开发送以完成绑定\n例:xxx@qq.com,xxxxx`) this.e.reply(`请将账号密码用逗号隔开发送以完成绑定\n例:账号xxx@qq.com,密码xxxxx`)
} }
async UserPassLogin() { async UserPassLogin() {
let msg = this.e.msg.replace(',|', ',').split(','); let msg = this.e.msg.replace(/账号|密码||:/g,'').replace(/,|/, ',').split(',');
if (msg.length != 2) { if (msg.length != 2) {
return false; return false;
} }
@ -128,4 +128,70 @@ export default class mysTopLogin {
await this.e.reply("验证超时", true) await this.e.reply("验证超时", true)
return false; return false;
} }
async showgoods(){
let goodslist = await this.goodsList()
if(!goodslist) return false;
let msg = ['当前支持的商品有:\n']
for (const [i, goods] of Object.entries(goodslist)) {
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`)
}
this.e.reply(msg)
return true;
}
async GetCode(){
try {
let msg = this.e.msg.replace(/,||\|/g, ' ').split(' ')
if (msg.length != 3) {
this.e.reply(`格式参考:#原神充值 6(商品ID) 120065390(uid)\n 可通过【#商品列表】获取可操作商品`)
return true;
}
let iswx = msg[0].includes('微信') ? 'weixin' : 'alipay'
if (msg[2].length != 9) {
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){
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}`])
} catch (error) {
this.e.reply('出问题了捏')
}
return true;
}
async goodsList() {
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]
}
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){
this.e.reply(`uid:${uid},订单:${order_no}已支付完成`)
}else{
this.e.reply(`订单:${order_no},${res.message}`)
}
return true
}
} }

View File

@ -293,7 +293,18 @@ export default class miHoYoApi {
url: `https://api-takumi.mihoyo.com/auth/api/getCookieAccountInfoByGameToken`, url: `https://api-takumi.mihoyo.com/auth/api/getCookieAccountInfoByGameToken`,
query: `account_id=${data.uid}&game_token=${data.token}` query: `account_id=${data.uid}&game_token=${data.token}`
}, },
GetCode:{
url:``,
query:``
},
goodsList:{
url:``,
query:``
},
checkOrder:{
url:``,
body:{}
}
} }
if (!urlMap[type]) return false if (!urlMap[type]) return false
let { let {