Files
tg-chat-bot/src/commands/unban.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

50 lines
1.9 KiB
TypeScript

import {Command} from "../base/command";
import {Requirements} from "../base/requirements";
import {Requirement} from "../base/requirement";
import {Message} from "typescript-telegram-bot-api";
import {bot, botUser} from "../index";
import {fullName, logError, oldReplyToMessage, oldSendMessage} from "../util/utils";
import {Environment} from "../common/environment";
export class Unban extends Command {
title = "/unban [reply]";
description = "unban user from chat";
requirements = Requirements.Build(
Requirement.BOT_ADMIN,
Requirement.CHAT,
Requirement.CHAT_ADMIN,
Requirement.BOT_CHAT_ADMIN,
Requirement.REPLY,
);
async execute(msg: Message) {
if (!msg.reply_to_message) return;
const user = msg.reply_to_message.from;
const userId = user.id;
if (userId === botUser.id) {
await oldReplyToMessage(msg, "Бот и так не в бане сам у себя.").catch(logError);
return;
}
if (userId === Environment.CREATOR_ID) {
await oldReplyToMessage(msg, "Создатель бота и так не в бане и никогда не будет.").catch(logError);
return;
}
if (msg.from.id !== Environment.CREATOR_ID && Environment.ADMIN_IDS.has(userId)) {
await oldReplyToMessage(msg, "Админимтраторы бота и так не в бане.").catch(logError);
return;
}
bot.unbanChatMember({chat_id: msg.chat.id, user_id: userId})
.then(async () => {
await oldSendMessage(msg, `${fullName(user)} разбанен ⛓️‍💥`).catch(logError);
})
.catch(async () => {
await oldSendMessage(msg, `Не смог разбанить ${fullName(user)} ☹️`).catch(logError);
});
}
}