UNPKG

stalkee

Version:

a Telegram bot who can send voice messages via inline mode added by admin with sorting them by numbers of uses

28 lines (27 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.remove = void 0; const telegraf_1 = require("telegraf"); const utils_1 = require("../../utils"); const controllers_1 = require("../../controllers"); const remove = async (ctx) => { try { const message = ctx.message?.reply_to_message; if (!message || !('voice' in message)) { return; } const fileUid = message.voice.file_unique_id; const affected = await (0, controllers_1.removeAudio)(fileUid); if (!affected) { await ctx.reply(ctx.t.commands.remove.res.not_found, telegraf_1.Extra.HTML()); return; } await ctx.reply(ctx.t.commands.remove.res.ok, telegraf_1.Extra.HTML()); utils_1.logger.info(`removed ${fileUid}`, 'command.remove'); } catch (err) { utils_1.logger.error(err, 'command.remove'); await ctx.reply(ctx.t.commands.remove.res.not_found, telegraf_1.Extra.HTML()); } }; exports.remove = remove;