mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-17 05:37:46 +00:00
feat: 获取原图
This commit is contained in:
parent
67c0bf7a0b
commit
6ba33447c0
2 changed files with 46 additions and 2 deletions
|
|
@ -21,6 +21,10 @@ export class Panel extends ZZZPlugin {
|
||||||
reg: `${rulePrefix}练度(统计)?$`,
|
reg: `${rulePrefix}练度(统计)?$`,
|
||||||
fnc: 'proficiency',
|
fnc: 'proficiency',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
reg: `${rulePrefix}原图$`,
|
||||||
|
fnc: 'getCharOriImage',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +115,18 @@ export class Panel extends ZZZPlugin {
|
||||||
uid: uid,
|
uid: uid,
|
||||||
charData: data,
|
charData: data,
|
||||||
};
|
};
|
||||||
await render(this.e, 'panel/card.html', finalData);
|
|
||||||
|
const res = await this.reply(
|
||||||
|
render(this.e, 'panel/card.html', finalData, {
|
||||||
|
retType: 'base64',
|
||||||
|
})
|
||||||
|
);
|
||||||
|
if (res?.message_id)
|
||||||
|
await redis.set(`ZZZ:PANEL:IMAGE:${res.message_id}`, data.role_icon, {
|
||||||
|
EX: 3600 * 3,
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
async proficiency() {
|
async proficiency() {
|
||||||
const uid = await this.getUID();
|
const uid = await this.getUID();
|
||||||
|
|
@ -158,4 +173,33 @@ export class Panel extends ZZZPlugin {
|
||||||
};
|
};
|
||||||
await render(this.e, 'proficiency/index.html', finalData);
|
await render(this.e, 'proficiency/index.html', finalData);
|
||||||
}
|
}
|
||||||
|
async getCharOriImage() {
|
||||||
|
let source;
|
||||||
|
if (this.e.getReply) {
|
||||||
|
source = await this.e.getReply();
|
||||||
|
} else if (this.e.source) {
|
||||||
|
if (this.e.group?.getChatHistory) {
|
||||||
|
// 支持at图片添加,以及支持后发送
|
||||||
|
source = (
|
||||||
|
await this.e.group.getChatHistory(this.e.source?.seq, 1)
|
||||||
|
).pop();
|
||||||
|
} else if (this.e.friend?.getChatHistory) {
|
||||||
|
source = (
|
||||||
|
await this.e.friend.getChatHistory(this.e.source?.time + 1, 1)
|
||||||
|
).pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const id = source?.message_id;
|
||||||
|
if (!id) {
|
||||||
|
await this.reply('未找到消息源,请引用要查看的图片');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const image = await redis.get(`ZZZ:PANEL:IMAGE:${id}`);
|
||||||
|
if (!image) {
|
||||||
|
await this.reply('未找到原图');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
await this.reply(segment.image(image));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import version from './version.js';
|
||||||
const render = (e, renderPath, renderData = {}, cfg = {}) => {
|
const render = (e, renderPath, renderData = {}, cfg = {}) => {
|
||||||
// 判断是否存在e.runtime
|
// 判断是否存在e.runtime
|
||||||
if (!e.runtime) {
|
if (!e.runtime) {
|
||||||
console.log('未找到e.runtime,请升级至最新版Yunzai');
|
logger.error('未找到e.runtime,请升级至最新版Yunzai');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取渲染精度配置
|
// 获取渲染精度配置
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue