UNPKG

stalkee

Version:

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

27 lines (26 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.actor = void 0; const telegraf_1 = require("telegraf"); const utils_1 = require("../../utils"); const controllers_1 = require("../../controllers"); const actor = async (ctx) => { try { const message = ctx.message?.reply_to_message; const actor = ctx.message?.text.split(/\s+/g).slice(1).join(' ') || ''; if (!message || !('voice' in message)) { return; } const fileUid = message.voice.file_unique_id; const oldActor = await (0, controllers_1.setActor)(fileUid, actor); await ctx.reply(ctx.t.commands.actor.res.ok .replace('{old_actor}', oldActor || '') .replace('{actor}', actor || '')); utils_1.logger.info(`set actor of ${fileUid} to ${actor}`, 'command.actor'); } catch (err) { utils_1.logger.error(err, 'command.actor'); await ctx.reply(ctx.t.commands.actor.res.not_found, telegraf_1.Extra.HTML()); } }; exports.actor = actor;