Files
tg-chat-bot/src/commands/unignore.ts
T
melod1n 13b41c3026 bump libs
migrate to typescript 6
remove ytdl feature
2026-05-01 07:05:17 +03:00

42 lines
1.5 KiB
TypeScript

import {Command} from "../base/command";
import {Requirements} from "../base/requirements";
import {Requirement} from "../base/requirement";
import {fullName, logError, oldSendMessage} from "../util/utils";
import {Message} from "typescript-telegram-bot-api";
import {botUser} from "../index";
import {Environment} from "../common/environment";
export class Unignore extends Command {
title = "/unignore";
description = "Bot will start responding to the user";
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 || !msg.reply_to_message.from) return;
const id = msg.reply_to_message.from.id;
const text = fullName(msg.reply_to_message.from);
if (id === botUser.id) {
await oldSendMessage(msg, "Бот и так всегда к себе прислушивается").catch(logError);
return;
}
if (id === Environment.CREATOR_ID) {
await oldSendMessage(msg, "Бот всегда слушает своего создателя").catch(logError);
return;
}
if (await Environment.removeMute(id)) {
await oldSendMessage(msg, text + " больше не в муте! 🔈").catch(logError);
} else {
await oldSendMessage(msg, text + " не был в муте 🤔").catch(logError);
}
}
}