user deletion/blocking
This commit is contained in:
32
src/index.js
32
src/index.js
@@ -43,6 +43,13 @@ const adminProductHandler = new AdminProductHandler(bot);
|
||||
// Start command - Create user profile
|
||||
bot.onText(/\/start/, async (msg) => {
|
||||
logDebug('/start', 'handleStart');
|
||||
|
||||
const canUse = await userHandler.canUseBot(msg);
|
||||
|
||||
if (!canUse) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await userHandler.handleStart(msg);
|
||||
} catch (error) {
|
||||
@@ -64,6 +71,16 @@ bot.onText(/\/admin/, async (msg) => {
|
||||
bot.on('message', async (msg) => {
|
||||
if (!msg.text) return;
|
||||
|
||||
if (msg.text.toLowerCase() === '/start') {
|
||||
return;
|
||||
}
|
||||
|
||||
const canUse = await userHandler.canUseBot(msg);
|
||||
|
||||
if (!canUse) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Check for admin location input
|
||||
if (await adminLocationHandler.handleLocationInput(msg)) {
|
||||
@@ -126,6 +143,13 @@ bot.on('callback_query', async (callbackQuery) => {
|
||||
const action = callbackQuery.data;
|
||||
const msg = callbackQuery.message;
|
||||
|
||||
const canUse = await userHandler.canUseBot(callbackQuery);
|
||||
|
||||
if (!canUse) {
|
||||
await bot.answerCallbackQuery(callbackQuery.id);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Profile and location management
|
||||
if (action === 'set_location') {
|
||||
@@ -211,7 +235,7 @@ bot.on('callback_query', async (callbackQuery) => {
|
||||
} else if (action === 'delete_location') {
|
||||
logDebug(action, 'handleDeleteLocation');
|
||||
await adminLocationHandler.handleDeleteLocation(callbackQuery);
|
||||
} else if (action.startsWith('confirm_delete_')) {
|
||||
} else if (action.startsWith('confirm_delete_location_')) {
|
||||
logDebug(action, 'handleConfirmDelete');
|
||||
await adminLocationHandler.handleConfirmDelete(callbackQuery);
|
||||
} else if (action === 'admin_menu') {
|
||||
@@ -264,9 +288,15 @@ bot.on('callback_query', async (callbackQuery) => {
|
||||
} else if (action.startsWith('delete_user_')) {
|
||||
logDebug(action, 'handleDeleteUser');
|
||||
await adminUserHandler.handleDeleteUser(callbackQuery);
|
||||
} else if (action.startsWith('block_user_')) {
|
||||
logDebug(action, 'handleDeleteUser');
|
||||
await adminUserHandler.handleBlockUser(callbackQuery);
|
||||
} else if (action.startsWith('confirm_delete_user_')) {
|
||||
logDebug(action, 'handleConfirmDelete');
|
||||
await adminUserHandler.handleConfirmDelete(callbackQuery);
|
||||
} else if (action.startsWith('confirm_block_user_')) {
|
||||
logDebug(action, 'handleConfirmBlock');
|
||||
await adminUserHandler.handleConfirmBlock(callbackQuery);
|
||||
} else if (action.startsWith('edit_user_balance_')) {
|
||||
logDebug(action, 'handleEditUserBalance');
|
||||
await adminUserHandler.handleEditUserBalance(callbackQuery);
|
||||
|
||||
Reference in New Issue
Block a user