mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 21:27:47 +00:00
fix: note
This commit is contained in:
parent
8f5e986038
commit
f0ef2bd624
4 changed files with 68 additions and 12 deletions
53
apps/gachalog.js
Normal file
53
apps/gachalog.js
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
import { ZZZPlugin } from '../lib/plugin.js';
|
||||||
|
import _ from 'lodash';
|
||||||
|
import render from '../lib/render.js';
|
||||||
|
import { ZZZNoteResp } from '../model/note.js';
|
||||||
|
import { rulePrefix } from '../lib/common.js';
|
||||||
|
|
||||||
|
export class GachaLog extends ZZZPlugin {
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
name: '[ZZZ-Plugin]GachaLog',
|
||||||
|
dsc: 'zzzGachaLog',
|
||||||
|
event: 'message',
|
||||||
|
priority: 100,
|
||||||
|
rule: [
|
||||||
|
{
|
||||||
|
reg: `${rulePrefix}抽卡记录$`,
|
||||||
|
fnc: 'gachaLog',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
async gachaLog(e) {
|
||||||
|
const { api, deviceFp } = await this.getAPI();
|
||||||
|
if (!api) return false;
|
||||||
|
let userData = await api.getData('zzzUser');
|
||||||
|
if (!userData?.data || _.isEmpty(userData.data.list)) {
|
||||||
|
await e.reply('[zzznote]玩家信息获取失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
userData = userData?.data?.list[0];
|
||||||
|
let noteData = await api.getData('zzzNote', { deviceFp });
|
||||||
|
noteData = await api.checkCode(e, noteData, 'zzzNote', {});
|
||||||
|
if (!noteData || noteData.retcode !== 0) {
|
||||||
|
await e.reply('[zzznote]每日数据获取失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
noteData = noteData.data;
|
||||||
|
noteData = new ZZZNoteResp(noteData);
|
||||||
|
let avatar = this.e.bot.avatar;
|
||||||
|
// 头像
|
||||||
|
if (this.e.member?.getAvatarUrl) {
|
||||||
|
avatar = await this.e.member.getAvatarUrl();
|
||||||
|
} else if (this.e.friend?.getAvatarUrl) {
|
||||||
|
avatar = await this.e.friend.getAvatarUrl();
|
||||||
|
}
|
||||||
|
const finalData = {
|
||||||
|
avatar,
|
||||||
|
player: userData,
|
||||||
|
note: noteData,
|
||||||
|
};
|
||||||
|
await render(e, 'note/index.html', finalData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
import { ZZZPlugin } from '../lib/plugin.js';
|
import { ZZZPlugin } from '../lib/plugin.js';
|
||||||
import MysZZZApi from '../lib/mysapi.js';
|
|
||||||
import { getCk } from '../lib/common.js';
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import render from '../lib/render.js';
|
import render from '../lib/render.js';
|
||||||
import { ZZZNoteResp } from '../model/note.js';
|
import { ZZZNoteResp } from '../model/note.js';
|
||||||
|
import { rulePrefix } from '../lib/common.js';
|
||||||
|
|
||||||
export class test extends ZZZPlugin {
|
export class Note extends ZZZPlugin {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
name: '[ZZZ-Plugin]Note',
|
name: '[ZZZ-Plugin]Note',
|
||||||
|
|
@ -14,7 +13,7 @@ export class test extends ZZZPlugin {
|
||||||
priority: 100,
|
priority: 100,
|
||||||
rule: [
|
rule: [
|
||||||
{
|
{
|
||||||
reg: `^#zzznote$`,
|
reg: `${rulePrefix}note$`,
|
||||||
fnc: 'note',
|
fnc: 'note',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -33,17 +33,17 @@ export default class MysZZZApi extends MysApi {
|
||||||
getServer() {
|
getServer() {
|
||||||
const _uid = this.uid.toString();
|
const _uid = this.uid.toString();
|
||||||
if (_uid.length < 10) {
|
if (_uid.length < 10) {
|
||||||
return game_region[this.game][0]; // 官服
|
return game_region[0]; // 官服
|
||||||
}
|
}
|
||||||
switch (_uid.slice(0, -8)) {
|
switch (_uid.slice(0, -8)) {
|
||||||
case '10':
|
case '10':
|
||||||
return game_region[this.game][2]; // 美服
|
return game_region[2]; // 美服
|
||||||
case '15':
|
case '15':
|
||||||
return game_region[this.game][3]; // 欧服
|
return game_region[3]; // 欧服
|
||||||
case '13':
|
case '13':
|
||||||
return game_region[this.game][4]; // 亚服
|
return game_region[4]; // 亚服
|
||||||
case '17':
|
case '17':
|
||||||
return game_region[this.game][5]; // 港澳台服
|
return game_region[5]; // 港澳台服
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,24 @@ import _ from 'lodash';
|
||||||
import NoteUser from '../../genshin/model/mys/NoteUser.js';
|
import NoteUser from '../../genshin/model/mys/NoteUser.js';
|
||||||
|
|
||||||
export class ZZZPlugin extends plugin {
|
export class ZZZPlugin extends plugin {
|
||||||
async getAPI() {
|
async getUID() {
|
||||||
let user = this.e;
|
let user = this.e;
|
||||||
if (this.e.at) {
|
if (this.e.at) {
|
||||||
user = this.e.at;
|
user = this.e.at;
|
||||||
}
|
}
|
||||||
this.User = await NoteUser.create(user);
|
this.User = await NoteUser.create(user);
|
||||||
logger.mark(this.User);
|
|
||||||
logger.mark(this.User.getUid('zzz'));
|
|
||||||
let uid = this.e.msg.match(/\d+/)?.[0];
|
let uid = this.e.msg.match(/\d+/)?.[0];
|
||||||
uid = uid || this.User?.getUid('zzz');
|
uid = uid || this.User?.getUid('zzz');
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
await this.reply('uid为空,米游社查询请先绑定cookie,其他查询请携带uid');
|
await this.reply('uid为空,米游社查询请先绑定cookie,其他查询请携带uid');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
async getAPI() {
|
||||||
|
uid = await this.getUID();
|
||||||
|
if (!uid) return false;
|
||||||
|
|
||||||
const ck = await getCk(this.e);
|
const ck = await getCk(this.e);
|
||||||
if (!ck || Object.keys(ck).filter(k => ck[k].ck).length === 0) {
|
if (!ck || Object.keys(ck).filter(k => ck[k].ck).length === 0) {
|
||||||
await this.reply('尚未绑定cookie,请先绑定cookie');
|
await this.reply('尚未绑定cookie,请先绑定cookie');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue