Files
tg-chat-bot/src/commands/help.ts
T
melod1n a736f786c2 feat(openai): add chat streaming and model commands
- add /openai (/chatgpt) chat command using OpenAI Responses API (streaming + incremental edits)
- add /openAIListModels, /openAIGetModel, /openAISetModel
- introduce base Command class and migrate non-chat commands to it
- wire OpenAI client + env vars (OPENAI_API_KEY, OPENAI_MODEL)
- bump deps (@google/genai, systeminformation, @types/node) and add openai
2026-02-03 13:39:01 +03:00

40 lines
1.5 KiB
TypeScript

import {Message} from "typescript-telegram-bot-api";
import {chatCommandToString, delay, logError, sendMessage} from "../util/utils";
import {Command} from "../base/command";
import {commands} from "../index";
import {TelegramError} from "typescript-telegram-bot-api/dist/errors";
export class Help extends Command {
command = ["h", "help"];
title = "/help";
description = "Show list of commands";
async execute(msg: Message) {
let text = "Commands:\n\n";
commands.forEach(c => {
text += `${chatCommandToString(c)}\n`;
});
await sendMessage({chat_id: msg.from.id, text: text})
.then(async () => {
if (msg.chat.type !== "private") {
await sendMessage({message: msg, text: "Отправил команды в ЛС 😎"}).catch(logError);
}
})
.catch(async (e) => {
if (e instanceof TelegramError) {
if (e.response?.error_code === 403) {
await sendMessage({
message: msg,
text: "Не смог отправить команды в ЛС ☹️\nТогда отправлю сюда"
}).catch(logError);
await delay(1000);
await sendMessage({message: msg, text: text}).catch(logError);
}
}
});
}
}