test
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
mol
2023-12-14 14:35:47 +08:00
parent 579d39fa4a
commit 16196c46ac
3 changed files with 106 additions and 4 deletions

93
plugins/cook/db/food.js Normal file
View File

@ -0,0 +1,93 @@
export const emojiMap = new Map([
[
'土豆', '🥔'
],
[
'胡萝卜', '🥕'
],
[
'花菜', '🥦'
],
[
'白萝卜', '🥣'
],
[
'西葫芦', '🥒'
],
[
'番茄', '🍅'
],
[
'西红柿', '🍅'
],
[
'芹菜', '🥬'
],
[
'黄瓜', '🥒'
],
[
'洋葱', '🧅'
],
[
'莴笋', '🎍'
],
[
'菌菇', '🍄'
],
[
'茄子', '🍆'
],
[
'豆腐', '🍲'
],
[
'包菜', '🥗'
],
[
'白菜', '🥬'
],
[
'午餐肉', '🥓'
],
[
'香肠', '🌭'
],
[
'腊肠', '🌭'
],
[
'鸡肉', '🐤'
],
[
'猪肉', '🐷'
],
[
'鸡蛋', '🥚'
],
[
'虾', '🦐'
],
[
'牛肉', '🐮'
],
[
'骨头', '🦴'
],
[
'鱼Todo', '🐟'
],
[
'面食', '🍝'
],
[
'面包', '🍞'
],
[
'米', '🍚'
],
[
'方便面', '🍜'
]
]
)

View File

@ -1,5 +1,6 @@
import pkg from 'node-csv';
import logger from '#root/utils/logger.js';
import { emojiMap } from './food.js'
import path from 'path';
const __dirname = path.dirname(new URL(import.meta.url).pathname);
@ -17,11 +18,19 @@ function parser() {
}
logger('食谱加载成功');
const keys = data.shift()
keys[0] = keys[0].slice(1)
recipeData = data.map(d => {
const res = {}
keys.forEach((key, index) => {
if (key) {
res[key] = d[index]
let text = d[index]
if (key === 'stuff') {
text = text.split('、').map(t => {
return `${emojiMap.has(t) ? emojiMap.get(t) + ' ' : ''}${t}`
}).join('、')
}
res[key] = text
}
})
return res
@ -42,5 +51,5 @@ export default async function getDb() {
}
// getDb().then((res) => {
// console.log(recipeData)
// // console.log(recipeData)
// })

View File

@ -3,7 +3,7 @@ export function genRecipeMessage(recipeList, header, footer) {
for (let recipe of recipeList) {
textList.push(
`${recipe['name']}\n准备材料:${recipe.stuff}\n使用厨具:${recipe.tools}\nhttps://www.bilibili.com/video/${recipe.bv}`,
`${recipe.name}\n材料:${recipe.stuff}\n厨具:${recipe.tools}\nhttps://www.bilibili.com/video/${recipe.bv}`,
);
}
@ -15,5 +15,5 @@ export function genRecipeMessage(recipeList, header, footer) {
textList.push(footer);
}
return textList.join('\n----------\n');
return textList.join('\n \n');
}