Create Delete
This commit is contained in:
25
core/scripts/telegrambot/utils/deleteuser.py
Normal file
25
core/scripts/telegrambot/utils/deleteuser.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
from dotenv import load_dotenv
|
||||||
|
from telebot import types
|
||||||
|
from utils.command import *
|
||||||
|
from utils.common import *
|
||||||
|
|
||||||
|
|
||||||
|
@bot.callback_query_handler(func=lambda call: call.data == "cancel_delete")
|
||||||
|
def handle_cancel_delete(call):
|
||||||
|
bot.edit_message_text("Operation canceled.", chat_id=call.message.chat.id, message_id=call.message.message_id)
|
||||||
|
create_main_markup(call.message)
|
||||||
|
|
||||||
|
@bot.message_handler(func=lambda message: is_admin(message.from_user.id) and message.text == 'Delete User')
|
||||||
|
def delete_user(message):
|
||||||
|
markup = types.InlineKeyboardMarkup()
|
||||||
|
cancel_button = types.InlineKeyboardButton("❌ Cancel", callback_data="cancel_delete")
|
||||||
|
markup.add(cancel_button)
|
||||||
|
|
||||||
|
msg = bot.reply_to(message, "Enter username:", reply_markup=markup)
|
||||||
|
bot.register_next_step_handler(msg, process_delete_user)
|
||||||
|
|
||||||
|
def process_delete_user(message):
|
||||||
|
username = message.text.strip().lower()
|
||||||
|
command = f"python3 {CLI_PATH} remove-user -u {username}"
|
||||||
|
result = run_cli_command(command)
|
||||||
|
bot.reply_to(message, result)
|
||||||
Reference in New Issue
Block a user