fix: Let last name empty if username doesn't have one

This commit is contained in:
GiovaniFZ 2024-09-08 14:00:48 -03:00
parent 7070a0e51f
commit 2f1997a4d0

View File

@ -4,9 +4,13 @@ const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(is
async function getUserInfo(ctx) { async function getUserInfo(ctx) {
const Strings = getStrings(ctx.from.language_code); const Strings = getStrings(ctx.from.language_code);
let lastName = ctx.from.last_name;
if (lastName === undefined) {
lastName = " ";
}
userInfo = Strings.userInfo userInfo = Strings.userInfo
.replace('{userName}', `${ctx.from.first_name} ${ctx.from.last_name}` || Strings.unKnown) .replace('{userName}', `${ctx.from.first_name} ${lastName}` || Strings.unKnown)
.replace('{userId}', ctx.from.id || Strings.unKnown) .replace('{userId}', ctx.from.id || Strings.unKnown)
.replace('{userHandle}', ctx.from.username ? `@${ctx.from.username}` : Strings.varNone) .replace('{userHandle}', ctx.from.username ? `@${ctx.from.username}` : Strings.varNone)
.replace('{userPremium}', ctx.from.is_premium ? Strings.varYes : Strings.varNo) .replace('{userPremium}', ctx.from.is_premium ? Strings.varYes : Strings.varNo)