BOT: List command improvement.

This commit is contained in:
root
2022-06-05 16:11:08 +00:00
parent e7ca5f868a
commit 6c5697ee7c

7
bot.py
View File

@ -52,6 +52,13 @@ def list_peers(update, context):
update.message.reply_text(f"{message}</code>", parse_mode='HTML', disable_web_page_preview=True)
else:
peer_name = "_".join(update.message.text.split()[1:])
if peer_name.isnumeric():
n = 1
for peer in wg_list_peers():
if int(peer_name) == n:
peer_name = peer['name']
break
n += 1
try:
update.message.reply_photo(
open(f'/etc/wireguard/clients_{config}/{peer_name}-qr.png', 'rb'), filename=f'{peer_name} QR.png', quote=True, caption=open(f'/etc/wireguard/clients_{config}/{peer_name}.conf', 'r').read())