koishi-plugin-cookerguide
Advanced tools
Comparing version 0.0.11 to 0.0.12
import { Context, Schema } from 'koishi'; | ||
export declare const name = "cookerguide"; | ||
export declare const usage = "\nmarkdown\u6A21\u677F\uFF1A\n\n #{{.tittle}}\n !{{.imgsize}}({{.img_url}})\n > {{.text1}}\n > {{.text2}}\n > {{.text3}}\n > {{.text4}}\n > {{.text5}}\n > {{.text6}}\n\n {{.text7}}\n\n\u672C\u63D2\u4EF6\u4EC5\u9650QQ\u5B98\u65B9bot\u4F7F\u7528\uFF0C\u4E14\u9700\u8981\u5F00\u542Fmarkdown\u6743\u9650\n"; | ||
export declare const usage = "\nmarkdown\u6A21\u677F\uFF1A\n{{.text1}}\n{{.text2}}\n{{.text3}}\n{{.text4}}\n{{.text5}}\n{{.text6}}\n\n\u672C\u63D2\u4EF6\u4EC5\u9650QQ\u5B98\u65B9bot\u4F7F\u7528\uFF0C\u4E14\u9700\u8981\u5F00\u542Fmarkdown\u6743\u9650\n"; | ||
export interface Config { | ||
@@ -5,0 +5,0 @@ mdid: string; |
@@ -9,18 +9,12 @@ "use strict"; | ||
const recipe_1 = __importDefault(require("./recipe/recipe")); | ||
const path_1 = require("path"); | ||
exports.name = 'cookerguide'; | ||
exports.usage = ` | ||
markdown模板: | ||
{{.text1}} | ||
{{.text2}} | ||
{{.text3}} | ||
{{.text4}} | ||
{{.text5}} | ||
{{.text6}} | ||
#{{.tittle}} | ||
!{{.imgsize}}({{.img_url}}) | ||
> {{.text1}} | ||
> {{.text2}} | ||
> {{.text3}} | ||
> {{.text4}} | ||
> {{.text5}} | ||
> {{.text6}} | ||
{{.text7}} | ||
本插件仅限QQ官方bot使用,且需要开启markdown权限 | ||
@@ -30,12 +24,12 @@ `; | ||
mdid: koishi_1.Schema.string().required(), | ||
key1: koishi_1.Schema.string().default('tittle'), | ||
key2: koishi_1.Schema.string().default('imgsize'), | ||
key3: koishi_1.Schema.string().default('img_url'), | ||
key4: koishi_1.Schema.string().default('text1'), | ||
key5: koishi_1.Schema.string().default('text2'), | ||
key6: koishi_1.Schema.string().default('text3'), | ||
key7: koishi_1.Schema.string().default('text4'), | ||
key8: koishi_1.Schema.string().default('text5'), | ||
key9: koishi_1.Schema.string().default('text6'), | ||
key10: koishi_1.Schema.string().default('text7'), | ||
key1: koishi_1.Schema.string().default('text1'), | ||
key2: koishi_1.Schema.string().default('text2'), | ||
key3: koishi_1.Schema.string().default('text3'), | ||
key4: koishi_1.Schema.string().default('text4'), | ||
key5: koishi_1.Schema.string().default('text5'), | ||
key6: koishi_1.Schema.string().default('text6'), | ||
key7: koishi_1.Schema.string().default('text7'), | ||
key8: koishi_1.Schema.string().default('text8'), | ||
key9: koishi_1.Schema.string().default('text9'), | ||
key10: koishi_1.Schema.string().default('text10'), | ||
}); | ||
@@ -46,3 +40,2 @@ let ingredients = {}; | ||
const { d } = session.event._data; | ||
console.log(d); | ||
try { | ||
@@ -62,3 +55,2 @@ await session.bot.internal.acknowledgeInteraction(session.event._data.d.id, { | ||
const msg_id = Adata.split(' ')[1]; | ||
const { url } = await session.app['server.temp'].create(`file://${(0, path_1.resolve)(`${__dirname}/img/1.jpg`)}`); | ||
const md = { | ||
@@ -75,10 +67,2 @@ content: "111", | ||
{ | ||
key: config.key2, | ||
values: ["[img#512px #512px]"] | ||
}, | ||
{ | ||
key: config.key3, | ||
values: [url] | ||
}, | ||
{ | ||
key: config.key4, | ||
@@ -141,3 +125,3 @@ values: ["请选择肉类,也可以跳过"] | ||
timestamp: session.timestamp, | ||
msg_seq: 3 | ||
msg_seq: Math.floor(Math.random() * 1000) | ||
}; | ||
@@ -160,7 +144,6 @@ await session.bot.internal.sendMessage(session.channelId, md); | ||
matchedRecipes.sort((recipe1, recipe2) => countMatches(recipe2, session, data) - countMatches(recipe1, session, data)); | ||
const { url } = await session.app['server.temp'].create(`file://${(0, path_1.resolve)(`${__dirname}/img/1.jpg`)}`); | ||
let btnLise = []; | ||
for (let i in matchedRecipes) { | ||
const url = "https://www.bilibili.com/video/" + matchedRecipes[i]?.bv; | ||
btnLise.push({ "buttons": [urlbtn(session.event.user.id, i.toString(), matchedRecipes[i]?.name, url)] }); | ||
btnLise.push({ "buttons": [urlbtn(i.toString(), matchedRecipes[i]?.name, url)] }); | ||
if (btnLise.length > 4) | ||
@@ -170,2 +153,3 @@ break; | ||
const cooklist = matchedRecipes?.slice(0, 5)?.map(recipe => recipe.name)?.join('\r'); | ||
console.log(cooklist); | ||
const md = { | ||
@@ -182,10 +166,2 @@ content: "111", | ||
{ | ||
key: config.key2, | ||
values: ["[img#256px #256px]"] | ||
}, | ||
{ | ||
key: config.key3, | ||
values: [url] | ||
}, | ||
{ | ||
key: config.key4, | ||
@@ -227,3 +203,3 @@ values: ["当前配料:"] | ||
timestamp: session.timestamp, | ||
msg_seq: 2 | ||
msg_seq: Math.floor(Math.random() * 1000) | ||
}; | ||
@@ -242,3 +218,2 @@ await session.bot.internal.sendMessage(session.channelId, md); | ||
return `该功能目前只在QQ群官方机器人开放,敬请期待后续更新`; | ||
const { url } = await session.app['server.temp'].create(`file://${(0, path_1.resolve)(`${__dirname}/img/1.jpg`)}`); | ||
const md = { | ||
@@ -255,10 +230,2 @@ content: "111", | ||
{ | ||
key: config.key2, | ||
values: ["[img#512px #512px]"] | ||
}, | ||
{ | ||
key: config.key3, | ||
values: [url] | ||
}, | ||
{ | ||
key: config.key4, | ||
@@ -313,3 +280,3 @@ values: ["请选择蔬菜,至少选择一样哦"] | ||
timestamp: session.timestamp, | ||
msg_seq: 1 | ||
msg_seq: Math.floor(Math.random() * 1000) | ||
}; | ||
@@ -323,3 +290,3 @@ await session.bot.internal.sendMessage(session.channelId, md); | ||
"label": b, | ||
"visited_label": `√${b}` | ||
"visited_label": `✅${b}` | ||
}, | ||
@@ -337,3 +304,3 @@ "action": { | ||
} | ||
function urlbtn(u, a, b, c) { | ||
function urlbtn(a, b, c) { | ||
return { | ||
@@ -340,0 +307,0 @@ "id": a, |
@@ -1,2 +0,2 @@ | ||
declare const t: { | ||
export interface Recipe { | ||
name: string; | ||
@@ -9,3 +9,4 @@ stuff: string[]; | ||
tools: string[]; | ||
}[]; | ||
} | ||
declare const t: Array<Recipe>; | ||
export { t as default }; |
{ | ||
"name": "koishi-plugin-cookerguide", | ||
"description": "烹饪指南", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"main": "lib/index.js", | ||
@@ -18,4 +18,4 @@ "typings": "lib/index.d.ts", | ||
"peerDependencies": { | ||
"koishi": "^4.16.8" | ||
"koishi": "^4.17.1" | ||
} | ||
} |
145828
6
5136