This commit is contained in:
@ -1,19 +1,21 @@
|
||||
import pkg from 'mirai-js'
|
||||
const { Message } = pkg
|
||||
|
||||
export function genRecipeMessage(recipeList, header, footer) {
|
||||
const textList = [];
|
||||
|
||||
for (let recipe of recipeList) {
|
||||
textList.push(
|
||||
`${recipe.name}\n材料:${recipe.stuff}\n厨具:${recipe.tools}\nhttps://www.bilibili.com/video/${recipe.bv}`,
|
||||
);
|
||||
}
|
||||
|
||||
const msg = new Message()
|
||||
if (header) {
|
||||
textList.unshift(header);
|
||||
msg.addText(`${header}\n`);
|
||||
}
|
||||
recipeList.forEach((recipe, index)=> {
|
||||
msg.addText(`${index}. ${recipe.name}\n`)
|
||||
msg.addText(`\t· 材料:${recipe.stuff}\n`)
|
||||
msg.addText(`\t· 厨具:${recipe.tools}\n`)
|
||||
msg.addText(`\t· 制作视频:https://www.bilibili.com/video/${recipe.bv}\n`)
|
||||
})
|
||||
|
||||
if (footer) {
|
||||
textList.push(footer);
|
||||
msg.addText(`${footer}`);
|
||||
}
|
||||
|
||||
return textList.join('\n \n');
|
||||
return msg
|
||||
}
|
||||
|
Reference in New Issue
Block a user