From ed40a902ef73ad7942e0dc0d89bbb76015c2f6da Mon Sep 17 00:00:00 2001 From: Akiru Date: Sun, 28 Jan 2024 11:52:54 +0000 Subject: [PATCH 1/2] bot/mod.ts aktualisiert Added new help command Refactored code to use variables inside the bot.api.setMy... functions. --- bot/mod.ts | 53 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/bot/mod.ts b/bot/mod.ts index 27b2e8d..1874810 100644 --- a/bot/mod.ts +++ b/bot/mod.ts @@ -12,6 +12,7 @@ import { img2imgCommand, img2imgQuestion } from "./img2imgCommand.ts"; import { pnginfoCommand, pnginfoQuestion } from "./pnginfoCommand.ts"; import { queueCommand } from "./queueCommand.ts"; import { txt2imgCommand, txt2imgQuestion } from "./txt2imgCommand.ts"; +import { helpCommand } from "./helpCommand.ts"; import { setConfig, getConfig } from "../app/config.ts"; // Set the new configuration @@ -117,31 +118,57 @@ bot.use(async (ctx, next) => { } }); +// Declare the bot description variable +export const botDescription = `I can generate furry images from text. +\`/txt2img Nyx\` + +If you want landscape or portrait: +\`/txt2img Nyx, Size: 576x832\` +\`/txt2img Nyx, Size: 832x576\` + +This bot uses the following model and will render nsfw and sfw: +\`EasyFluffV11.2.safetensors [821628644e]\` + +There is no loRA support. + +Please read about our terms of use: +https://nyx.akiru.de/disclaimer + +You can support Nyx by sending her a coffee :3 +ko-fi.com/nyxthebot`; + +// Short description constant +const botShortDescription = `Generate furry images from text. +Use /help for more information. +https://ko-fi.com/nyxthebot +https://nyx.akiru.de`; + +// Command descriptions +const botCommands = [ + { command: "txt2img", description: "Generate image from text" }, + { command: "img2img", description: "Generate image from image" }, + { command: "pnginfo", description: "Try to extract prompt from raw file" }, + { command: "queue", description: "Show the current queue" }, + { command: "cancel", description: "Cancel all your requests" }, + { command: "help", description: "Show bot description" }, +]; + // Wrap the calls in try-catch for error handling async function setupBotCommands() { try { - await bot.api.setMyShortDescription("Generate furry images in '704x704', '576x832', '832x576'. https://ko-fi.com/nyxthebot https://nyx.akiru.de/"); + await bot.api.setMyShortDescription(botShortDescription); } catch (err) { error(`Failed to set short description: ${err.message}`); } try { - await bot.api.setMyDescription( - "I can generate furry images from text. If you want a different size, use 'Size: 576x832' for example." + - "Send /txt2img to generate an image.", - ); + await bot.api.setMyDescription(botDescription); } catch (err) { error(`Failed to set description: ${err.message}`); } try { - await bot.api.setMyCommands([ - { command: "txt2img", description: "Generate image from text" }, - { command: "img2img", description: "Generate image from image" }, - { command: "pnginfo", description: "Try to extract prompt from raw file" }, - { command: "queue", description: "Show the current queue" }, - { command: "cancel", description: "Cancel all your requests" }, - ]); + await bot.api.setMyCommands(botCommands); } catch (err) { error(`Failed to set commands: ${err.message}`); } @@ -197,6 +224,8 @@ bot.command("queue", queueCommand); bot.command("cancel", cancelCommand); +bot.command("help", helpCommand); + bot.command("broadcast", broadcastCommand); bot.command("crash", () => { From e45ad9322945e2c084f79c36aa5707a32fd6b299 Mon Sep 17 00:00:00 2001 From: Akiru Date: Sun, 28 Jan 2024 11:55:18 +0000 Subject: [PATCH 2/2] =?UTF-8?q?bot/helpCommand.ts=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New function to send the bot description as help text. --- bot/helpCommand.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 bot/helpCommand.ts diff --git a/bot/helpCommand.ts b/bot/helpCommand.ts new file mode 100644 index 0000000..3d759c5 --- /dev/null +++ b/bot/helpCommand.ts @@ -0,0 +1,15 @@ +import { ErisContext } from "./mod.ts"; +import { omitUndef } from "../utils/omitUndef.ts"; +import { botDescription } from "./mod.ts"; // Import the description + +export async function helpCommand(ctx: ErisContext) { + await ctx.reply( + botDescription, // Send the stored description + omitUndef({ + reply_to_message_id: ctx.message?.message_id, + allow_sending_without_reply: true, + disable_web_page_preview: true, // Disable link previews + parse_mode: "Markdown" + }), + ); +} \ No newline at end of file