feat: base panel

This commit is contained in:
bietiaop 2024-07-12 02:43:32 +08:00
parent cbef7478c2
commit ac0c3d0d6c
12 changed files with 361 additions and 149 deletions

View file

@ -4,20 +4,28 @@ import _ from 'lodash';
import NoteUser from '../../genshin/model/mys/NoteUser.js';
export class ZZZPlugin extends plugin {
/**
*
* @returns {Promise<string>}
*/
async getUID() {
let user = this.e;
if (this.e.at) {
user = this.e.at;
}
this.User = await NoteUser.create(user);
let uid = this.e.msg.match(/\d+/)?.[0];
uid = uid || this.User?.getUid('zzz');
// let uid = this.e.msg.match(/\d+/)?.[0];
const uid = this.User?.getUid('zzz');
if (!uid) {
await this.reply('uid为空米游社查询请先绑定cookie其他查询请携带uid');
return false;
}
return uid;
}
/**
*
* @returns {Promise<{api: MysZZZApi, uid: string, deviceFp: string}>}
*/
async getAPI() {
let uid = await this.getUID();
if (!uid) return false;
@ -47,15 +55,17 @@ export class ZZZPlugin extends plugin {
}
return { api, uid, deviceFp };
}
/**
*
* @returns {Promise<boolean | object>}
*/
async getPlayerInfo() {
const { api } = await this.getAPI();
if (!api) return false;
let userData = await api.getData('zzzUser');
if (!userData?.data || _.isEmpty(userData.data.list)) {
await this.reply('[zzznote]玩家信息获取失败');
return false;
}
userData = userData?.data?.list[0];
let userData = await api.getFinalData(this.e, 'zzzUser');
if (!userData) return false;
userData = userData?.list[0];
let avatar = this.e.bot.avatar;
// 头像
if (this.e.member?.getAvatarUrl) {