Skip to content

Commit

Permalink
Fixed Add User
Browse files Browse the repository at this point in the history
  • Loading branch information
ReturnFI authored Sep 4, 2024
1 parent 74a7802 commit e952c83
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions core/scripts/telegrambot/tbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,21 @@ def process_add_user_step3(message, username, traffic_limit):
lower_username = username.lower()
command = f"python3 {CLI_PATH} add-user -u {username} -t {traffic_limit} -e {expiration_days}"
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_result = run_cli_command(qr_command).replace("IPv4:\n", "").strip()

if not qr_result:
bot.reply_to(message, "Failed to generate QR code.")
return

qr_v4 = qrcode.make(qr_result)
bio_v4 = io.BytesIO()
qr_v4.save(bio_v4, 'PNG')
bio_v4.seek(0)
caption = f"{result}"
bot.send_photo(message.chat.id, photo=bio_v4, caption=caption)
caption = f"{result}\n\n`{qr_result}`"
bot.send_photo(message.chat.id, photo=bio_v4, caption=caption, parse_mode="Markdown")

except ValueError:
bot.reply_to(message, "Invalid expiration days. Please enter a number.")

Expand Down

0 comments on commit e952c83

Please sign in to comment.