Fix Add User
This commit is contained in:
@ -52,14 +52,19 @@ def process_add_user_step1(message):
|
|||||||
|
|
||||||
command = f"python3 {CLI_PATH} list-users"
|
command = f"python3 {CLI_PATH} list-users"
|
||||||
result = run_cli_command(command)
|
result = run_cli_command(command)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
users = json.loads(result)
|
users = json.loads(result)
|
||||||
|
|
||||||
if username in users:
|
if username in users:
|
||||||
bot.reply_to(message, f"Username '{username}' already exists. Please choose a different username.")
|
bot.reply_to(message, f"Username '{username}' already exists. Please choose a different username.")
|
||||||
return
|
return
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
bot.reply_to(message, "Error retrieving user list. Please try again later.")
|
if "No such file or directory" in result or result.strip() == "":
|
||||||
return
|
bot.reply_to(message, "User list file does not exist. Adding the first user.")
|
||||||
|
else:
|
||||||
|
bot.reply_to(message, "Error retrieving user list. Please try again later.")
|
||||||
|
return
|
||||||
|
|
||||||
msg = bot.reply_to(message, "Enter traffic limit (GB):")
|
msg = bot.reply_to(message, "Enter traffic limit (GB):")
|
||||||
bot.register_next_step_handler(msg, process_add_user_step2, username)
|
bot.register_next_step_handler(msg, process_add_user_step2, username)
|
||||||
|
|||||||
Reference in New Issue
Block a user