mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
新增获取原图
指令,用于获取角色卡片的原图
This commit is contained in:
parent
ac8e368d9b
commit
9cba2fb426
@ -390,7 +390,7 @@ async function renderCard(e, avatar, render, renderType = "card") {
|
||||
e.reply(segment.image(process.cwd() + "/plugins/miao-plugin/resources/" + bg.img));
|
||||
} else {
|
||||
//渲染图像
|
||||
return await Common.render("character/card", {
|
||||
let msgRes = await Common.render("character/card", {
|
||||
save_id: uid,
|
||||
uid,
|
||||
talent,
|
||||
@ -400,6 +400,11 @@ async function renderCard(e, avatar, render, renderType = "card") {
|
||||
...getCharacterData(avatar),
|
||||
ds: char.getData("name,id,title,desc"),
|
||||
}, { e, render, scale: 1.6 });
|
||||
if (msgRes && msgRes.message_id) {
|
||||
// 如果消息发送成功,就将message_id和图片路径存起来,1小时过期
|
||||
await redis.set(`miao:original-picture:${msgRes.message_id}`, bg.img, {EX: 3600});
|
||||
}
|
||||
return msgRes;
|
||||
}
|
||||
|
||||
|
||||
@ -964,4 +969,35 @@ export async function getProfileAll(e) {
|
||||
export async function profileHelp(e) {
|
||||
e.reply(segment.image(`file://${process.cwd()}/plugins/miao-plugin/resources/character/imgs/help.jpg`))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取角色卡片的原图 */
|
||||
export async function getOriginalPicture(e) {
|
||||
if (!e.hasReply) {
|
||||
return;
|
||||
}
|
||||
// 引用的消息不是自己的消息
|
||||
if (e.source.user_id !== e.self_id) {
|
||||
return;
|
||||
}
|
||||
// 引用的消息不是纯图片
|
||||
if (!/^\[图片]$/.test(e.source.message)) {
|
||||
return;
|
||||
}
|
||||
// 获取原消息
|
||||
let source;
|
||||
if (e.isGroup) {
|
||||
source = (await e.group.getChatHistory(e.source.seq, 1)).pop();
|
||||
} else {
|
||||
source = (await e.friend.getChatHistory(e.source.time, 1)).pop();
|
||||
}
|
||||
if (source) {
|
||||
let imgPath = await redis.get(`miao:original-picture:${source.message_id}`);
|
||||
if (imgPath) {
|
||||
e.reply([segment.image(process.cwd() + "/plugins/miao-plugin/resources/" + imgPath)]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
e.reply("消息太过久远了,俺也忘了原图是啥了,下次早点来吧~");
|
||||
return true;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ export const render = async function (path, params, cfg) {
|
||||
});
|
||||
|
||||
if (base64) {
|
||||
e.reply(segment.image(`base64://${base64}`));
|
||||
return await e.reply(segment.image(`base64://${base64}`));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
10
index.js
10
index.js
@ -6,7 +6,8 @@ import {
|
||||
enemyLv,
|
||||
getArtis,
|
||||
getProfileAll,
|
||||
profileHelp
|
||||
profileHelp,
|
||||
getOriginalPicture
|
||||
} from "./apps/character.js";
|
||||
import { consStat, abyssPct, abyssTeam } from "./apps/stat.js";
|
||||
import { wiki, calendar } from "./apps/wiki.js";
|
||||
@ -34,7 +35,8 @@ export {
|
||||
getProfileAll,
|
||||
profileHelp,
|
||||
calendar,
|
||||
profileCfg
|
||||
profileCfg,
|
||||
getOriginalPicture
|
||||
};
|
||||
|
||||
|
||||
@ -60,6 +62,10 @@ let rule = {
|
||||
reg: wifeReg,
|
||||
describe: "【#角色】#老公 #老婆 查询",
|
||||
},
|
||||
getOriginalPicture: {
|
||||
reg: "^#(获取|给我|我要|求|发|发下|发个|发一下)?原图(吧|呗)?$",
|
||||
describe: "【#原图】 回复角色卡片,可获取原图",
|
||||
},
|
||||
consStat: {
|
||||
reg: "^#(喵喵)?角色(持有|持有率|命座|命之座|.命)(分布|统计|持有|持有率)?$",
|
||||
describe: "【#统计】 #角色持有率 #角色5命统计",
|
||||
|
Loading…
Reference in New Issue
Block a user