Skip to content

Commit

Permalink
fix bot
Browse files Browse the repository at this point in the history
  • Loading branch information
aleskxyz authored May 21, 2024
1 parent c4186c3 commit 113c6fa
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tgbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_users_ezpz():
local_command = command + '--list-users'
return run_command(local_command).split('\n')[:-1]
def get_config_ezpz(username):
local_command = command + f"--show-user {username} | grep -E '://|^{{\"dns\"'"
local_command = command + f"--show-user {username} | grep -E '://|^\\{{\"dns\"'"
return run_command(local_command).split('\n')[:-1]
def delete_user_ezpz(username):
local_command = command + f'--delete-user {username}'
Expand Down Expand Up @@ -68,16 +68,18 @@ def show_user(update, context, username):
keyboard = []
keyboard.append([InlineKeyboardButton('Back', callback_data='show_user')])
reply_markup = InlineKeyboardMarkup(keyboard)
context.bot.send_message(chat_id=update.effective_chat.id, text=f'Config for "{username}":')
context.bot.send_message(chat_id=update.effective_chat.id, text=f'Config for "{username}":', parse_mode='HTML')
config_list=get_config_ezpz(username)
ipv6_pattern = r'"server":"[0-9a-fA-F:]+"'
for index, config in enumerate(config_list):
if config.endswith("-ipv6") or re.search(ipv6_pattern, config):
config = "IPv6 Config:\n" + config
config = f"IPv6 Config:\n<pre>{config}</pre>"
else:
config = f"<pre>{config}</pre>"
if index == len(config_list) - 1:
context.bot.send_message(chat_id=update.effective_chat.id, text=config, reply_markup=reply_markup)
context.bot.send_message(chat_id=update.effective_chat.id, text=config, reply_markup=reply_markup, parse_mode='HTML')
else:
context.bot.send_message(chat_id=update.effective_chat.id, text=config)
context.bot.send_message(chat_id=update.effective_chat.id, text=config, parse_mode='HTML')

@restricted
def delete_user(update, context, username):
Expand Down

0 comments on commit 113c6fa

Please sign in to comment.