Skip to content

Commit

Permalink
Add /unban tgID option
Browse files Browse the repository at this point in the history
  • Loading branch information
grunch committed Aug 9, 2023
1 parent cac6724 commit bef0bec
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions bot/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,13 +502,18 @@ const initialize = (botToken, options) => {

bot.command('ban', adminMiddleware, async ctx => {
try {
let [username] = await validateParams(ctx, 2, '\\<_username or telegramID_\\>');
let [username] = await validateParams(
ctx,
2,
'\\<_username or telegram ID_\\>'
);

if (!username) return;

username = username[0] == '@' ? username.slice(1) : username;
let userTelegramId = username;
const user = await User.findOne({ $or: [{username : username},{tg_id:userTelegramId}] });
const user = await User.findOne({
$or: [{ username }, { tg_id: username }],
});
if (!user) {
await messages.notFoundUserMessage(ctx);
return;
Expand Down Expand Up @@ -540,13 +545,18 @@ const initialize = (botToken, options) => {

bot.command('unban', adminMiddleware, async ctx => {
try {
let [username] = await validateParams(ctx, 2, '\\<_username_\\>');
let [username] = await validateParams(
ctx,
2,
'\\<_username or telegram ID_\\>'
);

if (!username) return;

username = username[0] == '@' ? username.slice(1) : username;

const user = await User.findOne({ username });
const user = await User.findOne({
$or: [{ username }, { tg_id: username }],
});
if (!user) {
await messages.notFoundUserMessage(ctx);
return;
Expand Down

0 comments on commit bef0bec

Please sign in to comment.