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.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.location = void 0; const telegraf_1 = require("telegraf"); const utils_1 = require("../../utils"); const controllers_1 = require("../../controllers"); const location = async (ctx) => { try { const message = ctx.message?.reply_to_message; const location = ctx.message?.text.split(/\s+/g).slice(1).join(' ') || ''; if (!message || !('voice' in message)) { return; } const fileUid = message.voice.file_unique_id; const oldLocation = await (0, controllers_1.setLocation)(fileUid, location); await ctx.reply(ctx.t.commands.location.res.ok .replace('{old_location}', oldLocation || '') .replace('{location}', location || '')); utils_1.logger.info(`set location of ${fileUid} to ${location}`, 'command.location'); } catch (err) { utils_1.logger.error(err, 'command.location'); await ctx.reply(ctx.t.commands.location.res.not_found, telegraf_1.Extra.HTML()); } }; exports.location = location;