UNPKG

stalkee

Version:

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

36 lines (35 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.selectAudiosByActorAndLocation = void 0; const utils_1 = require("../utils"); const models_1 = require("../models"); const selectAudiosByActorAndLocation = async (actor, location) => { try { actor = actor.toLowerCase(); location = location.toLowerCase(); if (actor) { const actorEntity = await models_1.ActorAlias.findOneBy({ alias: actor }); actor = actorEntity?.actor || ''; } if (location) { const locationEntity = await models_1.LocationAlias.findOneBy({ alias: location }); location = locationEntity?.location || ''; } return await models_1.Audio.find({ take: utils_1.config.limits.max_result_size, order: { nUses: 'DESC' }, where: { actor: actor || undefined, location: location || undefined, } }); } catch (err) { utils_1.logger.error('' + err, 'controller.select_audios_by_actor_and_location'); } }; exports.selectAudiosByActorAndLocation = selectAudiosByActorAndLocation;