mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 05:07:46 +00:00
feat: 查询其他人&设置允许/禁止查询其他人
This commit is contained in:
parent
8981fa84e9
commit
606109f4b3
7 changed files with 29 additions and 17 deletions
|
|
@ -3,6 +3,7 @@ import render from '../lib/render.js';
|
|||
import { rulePrefix } from '../lib/common.js';
|
||||
import { getAuthKey } from '../lib/authkey.js';
|
||||
import settings from '../lib/settings.js';
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
anaylizeGachaLog,
|
||||
updateGachaLog,
|
||||
|
|
@ -81,6 +82,14 @@ export class GachaLog extends ZZZPlugin {
|
|||
async refreshGachaLog() {
|
||||
const uid = await this.getUID();
|
||||
if (!uid) return false;
|
||||
const lastQueryTime = await redis.get(`ZZZ:GACHA:${uid}:LASTTIME`);
|
||||
const gachaConfig = settings.getConfig('gacha');
|
||||
const coldTime = _.get(gachaConfig, 'interval', 300);
|
||||
if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) {
|
||||
await this.reply(`${coldTime}秒内只能刷新一次,请稍后再试`);
|
||||
return false;
|
||||
}
|
||||
await redis.set(`ZZZ:GACHA:${uid}:LASTTIME`, Date.now());
|
||||
try {
|
||||
const key = await getAuthKey(this.e, this.User, uid);
|
||||
if (!key) {
|
||||
|
|
@ -97,13 +106,6 @@ export class GachaLog extends ZZZPlugin {
|
|||
if (!uid) {
|
||||
return false;
|
||||
}
|
||||
const lastQueryTime = await redis.get(`ZZZ:GACHA:${uid}:LASTTIME`);
|
||||
const coldTime = settings.getConfig('gacha').interval || 300;
|
||||
if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) {
|
||||
await this.reply(`${coldTime}秒内只能刷新一次,请稍后再试`);
|
||||
return false;
|
||||
}
|
||||
await redis.set(`ZZZ:GACHA:${uid}:LASTTIME`, Date.now());
|
||||
this.reply('正在更新抽卡记录,可能需要一段时间,请耐心等待');
|
||||
const { data, count } = await updateGachaLog(key, uid);
|
||||
let msg = `抽卡记录更新成功,共${Object.keys(data).length}个卡池`;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ export class Panel extends ZZZPlugin {
|
|||
const uid = await this.getUID();
|
||||
if (!uid) return;
|
||||
const lastQueryTime = await redis.get(`ZZZ:PANEL:${uid}:LASTTIME`);
|
||||
const coldTime = settings.getConfig('panel').interval || 300;
|
||||
const panelSettings = settings.getConfig('panel');
|
||||
const coldTime = _.get(panelSettings, 'interval', 300);
|
||||
if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) {
|
||||
await this.reply(`${coldTime}秒内只能刷新一次,请稍后再试`);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
render:
|
||||
scale: 100
|
||||
query:
|
||||
others: true
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ export function supportGuoba() {
|
|||
placeholder: '请输入数字',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'config.query.others',
|
||||
label: '允许查询他人信息',
|
||||
bottomHelpMessage: '是否允许查询他人信息',
|
||||
component: 'Switch',
|
||||
},
|
||||
{
|
||||
component: 'Divider',
|
||||
label: '抽卡设置',
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import MysZZZApi from './mysapi.js';
|
|||
import { getCk } from './common.js';
|
||||
import _ from 'lodash';
|
||||
import NoteUser from '../../genshin/model/mys/NoteUser.js';
|
||||
import settings from '../lib/settings.js';
|
||||
|
||||
export class ZZZPlugin extends plugin {
|
||||
/**
|
||||
|
|
@ -10,7 +11,10 @@ export class ZZZPlugin extends plugin {
|
|||
*/
|
||||
async getUID() {
|
||||
let user = this.e;
|
||||
if (this.e.at) {
|
||||
const query = settings.getConfig('config').query;
|
||||
const allow = _.get(query, 'others', true);
|
||||
if (this.e.at && allow) {
|
||||
this.e.user_id = this.e.at;
|
||||
user = this.e.at;
|
||||
}
|
||||
this.User = await NoteUser.create(user);
|
||||
|
|
@ -29,9 +33,6 @@ export class ZZZPlugin extends plugin {
|
|||
async getAPI() {
|
||||
let uid = await this.getUID();
|
||||
if (!uid) return false;
|
||||
if (this.e.at) {
|
||||
this.e.user_id = this.e.at;
|
||||
}
|
||||
const ck = await getCk(this.e);
|
||||
if (!ck || Object.keys(ck).filter(k => ck[k].ck).length === 0) {
|
||||
await this.reply('尚未绑定cookie,请先绑定cookie');
|
||||
|
|
@ -69,8 +70,9 @@ export class ZZZPlugin extends plugin {
|
|||
if (!userData) return false;
|
||||
userData = userData?.list[0];
|
||||
let avatar = this.e.bot.avatar;
|
||||
// 头像
|
||||
if (this.e.member?.getAvatarUrl) {
|
||||
if (this.e?.user_id) {
|
||||
avatar = `https://q1.qlogo.cn/g?b=qq&s=0&nk=${this.e.user_id}`;
|
||||
} else if (this.e.member?.getAvatarUrl) {
|
||||
avatar = await this.e.member.getAvatarUrl();
|
||||
} else if (this.e.friend?.getAvatarUrl) {
|
||||
avatar = await this.e.friend.getAvatarUrl();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ function render(e, renderPath, renderData = {}, cfg = {}) {
|
|||
return {
|
||||
player: e?.playerCard?.player,
|
||||
avatar: e?.playerCard?.avatar,
|
||||
qqId: e?.at || e.user_id,
|
||||
...data,
|
||||
_res_path: resPath,
|
||||
_layout_path: layoutPath,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<link rel="stylesheet" type="text/css" href="{{@sys.resourcesPath}}/common/layout/playerinfo.css" />
|
||||
<div class="user-info">
|
||||
<div class="avatar">
|
||||
<img src="https://q1.qlogo.cn/g?b=qq&s=0&nk={{qqId}}}'" alt="Avatar">
|
||||
<img src="{{avatar}}'" alt="Avatar">
|
||||
</div>
|
||||
<div class="info-bar">
|
||||
<div class="info">
|
||||
|
|
@ -11,4 +11,4 @@
|
|||
</div>
|
||||
<div class="uid">UID {{player.game_uid}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue