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.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.selectAudios = void 0;
const utils_1 = require("../utils");
const _1 = require(".");
const selectAudios = async (query) => {
try {
if (!query) {
return await (0, _1.selectAllAudios)() || [];
}
else if (query.length > 1 && query.startsWith('"') && query.endsWith('"')) {
return await (0, _1.selectAudiosBySubstring)(query.slice(1, -1)) || [];
}
else if (query.length > 1 && (query.startsWith('@') || query.startsWith('~'))) {
let first = query.slice(1);
let second = '';
const secondMarker = query[0] == '@' ? '~' : '@';
const secondMarkerIndex = first.indexOf(secondMarker);
if (secondMarkerIndex > -1) {
second = first.slice(secondMarkerIndex + 1).trim();
first = first.slice(0, secondMarkerIndex).trim();
}
const [actor, location] = secondMarker == '@' ? [second, first] : [first, second];
return await (0, _1.selectAudiosByActorAndLocation)(actor, location) || [];
}
else {
return await (0, _1.selectAudiosByWords)(query.split(' ')) || [];
}
}
catch (err) {
utils_1.logger.error('' + err, 'controller.select_audios');
return [];
}
};
exports.selectAudios = selectAudios;