2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-31 06:05:22 +00:00

check if username exists before using methods

This commit is contained in:
Pouria Ezzati
2017-10-11 21:34:05 +03:30
parent 752d839624
commit b8cba2595f
2 changed files with 2 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ const addUserHandler = async (ctx, next) => {
isAdmin: user && user.status === 'admin', isAdmin: user && user.status === 'admin',
isMaster: user && isMaster: user &&
user.id === Number(master) || user.id === Number(master) ||
user.username &&
user.username.toLowerCase() === user.username.toLowerCase() ===
String(master).replace('@', '').toLowerCase(), String(master).replace('@', '').toLowerCase(),
user: newUser, user: newUser,

View File

@@ -11,6 +11,7 @@ const addedToGroupHandler = async (ctx, next) => {
const msg = ctx.message; const msg = ctx.message;
const { telegram } = ctx; const { telegram } = ctx;
const isMaster = ctx.from.id === Number(master) || const isMaster = ctx.from.id === Number(master) ||
ctx.from.username &&
ctx.from.username.toLowerCase() === ctx.from.username.toLowerCase() ===
String(master).replace('@', '').toLowerCase(); String(master).replace('@', '').toLowerCase();