forked from pinks/eris
1
0
Fork 0

Compare commits

...

3 Commits

Author SHA1 Message Date
Akiru d266b8e342 Merge pull request 'helpCommand added' (#3) from helpCommand into main
Reviewed-on: #3
2024-01-28 11:55:48 +00:00
Akiru e45ad93229 bot/helpCommand.ts hinzugefügt
New function to send the bot description as help text.
2024-01-28 11:55:18 +00:00
Akiru ed40a902ef bot/mod.ts aktualisiert
Added new help command
Refactored code to use variables inside the bot.api.setMy... functions.
2024-01-28 11:52:54 +00:00
2 changed files with 56 additions and 12 deletions

15
bot/helpCommand.ts Normal file
View File

@ -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"
}),
);
}

View File

@ -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", () => {