stalkee
Version:
a Telegram bot who can send voice messages via inline mode added by admin with sorting them by numbers of uses
20 lines (19 loc) • 637 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.setLocale = void 0;
const utils_1 = require("../../utils");
const models_1 = require("../../models");
const setLocale = async (ctx, next) => {
if (!ctx.from) {
return await next();
}
try {
const user = await models_1.User.findOneByOrFail({ id: ctx.from.id });
ctx.t = utils_1.i18n[user.language] || utils_1.i18n[utils_1.config.bot.locales[0]];
return await next();
}
catch (err) {
utils_1.logger.error(err, 'middleware.set_locale');
}
};
exports.setLocale = setLocale;