Fix Add User
This commit is contained in:
@ -52,12 +52,17 @@ def process_add_user_step1(message):
|
||||
|
||||
command = f"python3 {CLI_PATH} list-users"
|
||||
result = run_cli_command(command)
|
||||
|
||||
try:
|
||||
users = json.loads(result)
|
||||
|
||||
if username in users:
|
||||
bot.reply_to(message, f"Username '{username}' already exists. Please choose a different username.")
|
||||
return
|
||||
except json.JSONDecodeError:
|
||||
if "No such file or directory" in result or result.strip() == "":
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user