This commit is contained in:
bietiaop 2024-07-08 16:27:34 +08:00
parent 5d109ef51c
commit 4828a31163
11 changed files with 100 additions and 126 deletions

View file

@ -1,45 +1,24 @@
import MysZZZApi from './mysapi.js';
import { getCk } from './common.js';
import _ from 'lodash';
import NoteUser from '../../genshin/model/mys/NoteUser.js';
export class ZZZPlugin extends plugin {
async miYoSummerGetUid() {
const key = `ZZZ:UID:${this.e.user_id}`;
const ck = await getCk(this.e);
if (!ck) return false;
let api = new MysZZZApi('', ck);
let userData = await api.getData('zzzUser');
if (!userData?.data || _.isEmpty(userData.data.list)) return false;
userData = userData.data.list[0];
let { game_uid: gameUid } = userData;
await redis.set(key, gameUid);
await redis.setEx(
`ZZZ:userData:${gameUid}`,
60 * 60,
JSON.stringify(userData)
);
return userData;
}
async getAPI() {
let user = this.e.user_id;
let ats = this.e.message.filter(m => m.type === 'at');
if (ats.length > 0 && !e.atBot) {
user = ats[0].qq;
this.e.user_id = user;
this.User = new User(this.e);
let user = this.e;
if (this.e.at) {
user = this.e.at;
}
this.User = new NoteUser(user);
let uid = this.e.msg.match(/\d+/)?.[0];
await this.miYoSummerGetUid();
uid =
uid || (await redis.get(`ZZZ:UID:${user}`)) || this.e.user?.getUid('zzz');
uid = uid || this.User?.getUid('zzz');
if (!uid) {
await this.reply('尚未绑定uid,请发送#zzz绑定uid进行绑定');
await this.reply('uid为空米游社查询请先绑定cookie其他查询请携带uid');
return false;
}
const ck = await getCk(this.e);
if (!ck || Object.keys(ck).filter(k => ck[k].ck).length === 0) {
await this.reply('尚未绑定cookie请先使用逍遥插件绑定cookie');
await this.reply('尚未绑定cookie请先绑定cookie');
return false;
}