initial upload

This commit is contained in:
bietiaop 2024-07-08 13:13:22 +08:00
commit 1c65f10e24
58 changed files with 2533 additions and 0 deletions

26
apps/bind.js Normal file
View file

@ -0,0 +1,26 @@
import { rulePrefix } from '../lib/common.js';
import { ZZZPlugin } from '../lib/plugin.js';
export class bind extends ZZZPlugin {
constructor() {
super({
name: '[ZZZ-Plugin]Bind',
dsc: 'zzzbind',
event: 'message',
priority: 100,
rule: [
{
reg: `^${rulePrefix}绑定(uid|UID)?(\\s)?[1-9][0-9]{7,9}$`,
fnc: 'bindUid',
},
],
});
}
async bindUid() {
const uid = parseInt(this.e.msg.replace(/[^0-9]/gi, ''));
const user = this.e.user_id;
await redis.set(`ZZZ:UID:${user}`, uid);
this.reply(`绑定成功,当前绑定[zzz]uid:${uid}`, false);
return false;
}
}

53
apps/note.js Normal file
View file

@ -0,0 +1,53 @@
import { ZZZPlugin } from '../lib/plugin.js';
import MysZZZApi from '../lib/mysapi.js';
import { getCk } from '../lib/common.js';
import _ from 'lodash';
import render from '../lib/render.js';
import { ZZZNoteResp } from '../model/note.js';
export class test extends ZZZPlugin {
constructor() {
super({
name: '[ZZZ-Plugin]Note',
dsc: 'zzznote',
event: 'message',
priority: 100,
rule: [
{
reg: `^#zzznote$`,
fnc: 'note',
},
],
});
}
async note(e) {
const { api, deviceFp } = await this.getAPI();
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);
}
}