From 16196c46acfb42c85b1490713693358dd2685dcd Mon Sep 17 00:00:00 2001 From: mol Date: Thu, 14 Dec 2023 14:35:47 +0800 Subject: [PATCH] test --- plugins/cook/db/food.js | 93 +++++++++++++++++++++++++++++++++++++ plugins/cook/db/index.js | 13 +++++- plugins/cook/utils/index.js | 4 +- 3 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 plugins/cook/db/food.js diff --git a/plugins/cook/db/food.js b/plugins/cook/db/food.js new file mode 100644 index 0000000..18fe4f1 --- /dev/null +++ b/plugins/cook/db/food.js @@ -0,0 +1,93 @@ +export const emojiMap = new Map([ + [ + 'ๅœŸ่ฑ†', '๐Ÿฅ”' + ], + [ + '่ƒก่ๅœ', '๐Ÿฅ•' + ], + [ + '่Šฑ่œ', '๐Ÿฅฆ' + ], + [ + '็™ฝ่ๅœ', '๐Ÿฅฃ' + ], + [ + '่ฅฟ่‘ซ่Šฆ', '๐Ÿฅ’' + ], + [ + '็•ช่Œ„', '๐Ÿ…' + ], + [ + '่ฅฟ็บขๆŸฟ', '๐Ÿ…' + ], + [ + '่Šน่œ', '๐Ÿฅฌ' + ], + [ + '้ป„็“œ', '๐Ÿฅ’' + ], + [ + 'ๆด‹่‘ฑ', '๐Ÿง…' + ], + [ + '่Žด็ฌ‹', '๐ŸŽ' + ], + [ + '่Œ่‡', '๐Ÿ„' + ], + [ + '่Œ„ๅญ', '๐Ÿ†' + ], + [ + '่ฑ†่…', '๐Ÿฒ' + ], + [ + 'ๅŒ…่œ', '๐Ÿฅ—' + ], + [ + '็™ฝ่œ', '๐Ÿฅฌ' + ], + [ + 'ๅˆ้ค่‚‰', '๐Ÿฅ“' + ], + [ + '้ฆ™่‚ ', '๐ŸŒญ' + ], + [ + '่…Š่‚ ', '๐ŸŒญ' + ], + [ + '้ธก่‚‰', '๐Ÿค' + ], + [ + '็Œช่‚‰', '๐Ÿท' + ], + [ + '้ธก่›‹', '๐Ÿฅš' + ], + [ + '่™พ', '๐Ÿฆ' + ], + [ + '็‰›่‚‰', '๐Ÿฎ' + ], + [ + '้ชจๅคด', '๐Ÿฆด' + ], + [ + '้ฑผ๏ผˆTodo๏ผ‰', '๐ŸŸ' + ], + [ + '้ข้ฃŸ', '๐Ÿ' + ], + [ + '้ขๅŒ…', '๐Ÿž' + ], + [ + '็ฑณ', '๐Ÿš' + ], + [ + 'ๆ–นไพฟ้ข', '๐Ÿœ' + ] +] +) \ No newline at end of file diff --git a/plugins/cook/db/index.js b/plugins/cook/db/index.js index 9ffc585..3cc933d 100644 --- a/plugins/cook/db/index.js +++ b/plugins/cook/db/index.js @@ -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) // }) diff --git a/plugins/cook/utils/index.js b/plugins/cook/utils/index.js index 62e1ec0..58dd557 100644 --- a/plugins/cook/utils/index.js +++ b/plugins/cook/utils/index.js @@ -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'); }