Fixed Add User
This commit is contained in:
@ -90,10 +90,11 @@ def process_add_user_step3(message, username, traffic_limit):
|
|||||||
lower_username = username.lower()
|
lower_username = username.lower()
|
||||||
command = f"python3 {CLI_PATH} add-user -u {username} -t {traffic_limit} -e {expiration_days}"
|
command = f"python3 {CLI_PATH} add-user -u {username} -t {traffic_limit} -e {expiration_days}"
|
||||||
result = run_cli_command(command)
|
result = run_cli_command(command)
|
||||||
qr_command = f"python3 {CLI_PATH} show-user-uri -u {lower_username} -ip 4"
|
|
||||||
qr_result = run_cli_command(qr_command)
|
|
||||||
|
|
||||||
if qr_result.strip() == "":
|
qr_command = f"python3 {CLI_PATH} show-user-uri -u {lower_username} -ip 4"
|
||||||
|
qr_result = run_cli_command(qr_command).replace("IPv4:\n", "").strip()
|
||||||
|
|
||||||
|
if not qr_result:
|
||||||
bot.reply_to(message, "Failed to generate QR code.")
|
bot.reply_to(message, "Failed to generate QR code.")
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -101,8 +102,8 @@ def process_add_user_step3(message, username, traffic_limit):
|
|||||||
bio_v4 = io.BytesIO()
|
bio_v4 = io.BytesIO()
|
||||||
qr_v4.save(bio_v4, 'PNG')
|
qr_v4.save(bio_v4, 'PNG')
|
||||||
bio_v4.seek(0)
|
bio_v4.seek(0)
|
||||||
caption = f"{result}"
|
caption = f"{result}\n\n`{qr_result}`"
|
||||||
bot.send_photo(message.chat.id, photo=bio_v4, caption=caption)
|
bot.send_photo(message.chat.id, photo=bio_v4, caption=caption, parse_mode="Markdown")
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
bot.reply_to(message, "Invalid expiration days. Please enter a number.")
|
bot.reply_to(message, "Invalid expiration days. Please enter a number.")
|
||||||
|
|||||||
Reference in New Issue
Block a user