From a4281342182d1a7326595438a7aef5cd649ea6cb Mon Sep 17 00:00:00 2001 From: Danil Nikolaev Date: Thu, 22 Jan 2026 17:04:38 +0300 Subject: [PATCH] add debug command --- src/commands/debug.ts | 17 +++++++++++++++++ src/index.ts | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 src/commands/debug.ts diff --git a/src/commands/debug.ts b/src/commands/debug.ts new file mode 100644 index 0000000..959ba3e --- /dev/null +++ b/src/commands/debug.ts @@ -0,0 +1,17 @@ +import {ChatCommand} from "../base/chat-command"; +import {Message} from "typescript-telegram-bot-api"; +import {Requirements} from "../base/requirements"; +import {Requirement} from "../base/requirement"; +import {logError, replyToMessage} from "../util/utils"; + +export class Debug extends ChatCommand { + requirements = Requirements.Build(Requirement.BOT_ADMIN); + + async execute(msg: Message): Promise { + const msgToDebug = msg.reply_to_message ? msg.reply_to_message : msg; + + const json = JSON.stringify(msgToDebug, null, 2); + const text = `\`\`\`json\n${json}\n\`\`\``; + await replyToMessage({message: msg, text: text, parse_mode: "Markdown"}).catch(logError); + } +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index bda5f21..7e136ea 100644 --- a/src/index.ts +++ b/src/index.ts @@ -69,6 +69,7 @@ import {MistralListModels} from "./commands/mistral-list-models"; import {GeminiListModels} from "./commands/gemini-list-models"; import {GeminiGetModel} from "./commands/gemini-get-model"; import {GeminiSetModel} from "./commands/gemini-set-model"; +import {Debug} from "./commands/debug"; process.setUncaughtExceptionCaptureCallback(console.error); @@ -150,6 +151,7 @@ export const chatCommands: ChatCommand[] = [ new Dice(), new Title(), new Transliteration(), + new Debug(), new AdminsAdd(), new AdminsRemove(),