Skip to content

Commit

Permalink
fix(admin): fix check_user_configs by tg id
Browse files Browse the repository at this point in the history
  • Loading branch information
exmanka committed Jan 30, 2024
1 parent 0b3a6a9 commit ac66fcc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/database/postgres_dbms.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ async def get_clientID_by_telegramID(telegram_id: int) -> int | None:
FROM clients
WHERE telegram_id = $1;
''',
telegram_id)
telegram_id)


async def get_clientID_by_username(username: str) -> int | None:
Expand Down
34 changes: 17 additions & 17 deletions src/handlers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def fsm_reset(message: Message, state: FSMContext):
@admin_mw.admin_only()
async def show_admin_keyboard(message: Message):
"""Send message with information about admin's commands and show admin keyboard."""
await message.reply(loc.admn.msgs['admin_kb_info'], reply_markup=admin_kb.menu)
await message.reply(loc.admn.msgs['admin_kb_info'], parse_mode='HTML', reply_markup=admin_kb.menu)


@admin_mw.admin_only()
Expand Down Expand Up @@ -225,7 +225,7 @@ async def show_user_config_sql_cm_start(message: Message):

@admin_mw.admin_only()
async def show_user_config_sql(message: Message):
"""Send message with SQL auery for INSERT of configuration provided by admin."""
"""Send message with SQL qauery for INSERT of configuration provided by admin."""
# parse arguments
if message.photo or message.document:
arguments = message.caption.split(' ')
Expand Down Expand Up @@ -458,20 +458,21 @@ async def show_logs(message: Message):

@admin_mw.admin_only()
async def check_user_configs(message: Message):
"""Send messages with configurations of another client.
Used for test.
"""
# taking user info (telegramID or username) from text after command
user_info = message.text.split(' ')[1]
"""Send messages with configurations of another client."""
try:
# taking user info (telegramID or username) from text after command
user_info = message.text.split(' ')[1]

# if user_info is username
if user_info[0] == '@':
client_id = await postgres_dbms.get_clientID_by_username(user_info)
# if user_info is username
if user_info[0] == '@':
client_id = await postgres_dbms.get_clientID_by_username(user_info)

# if user_info is user telegramID
else:
client_id = await postgres_dbms.get_clientID_by_telegramID(user_info)
# if user_info is user telegramID
else:
client_id = await postgres_dbms.get_clientID_by_telegramID(int(user_info))
except Exception as e:
await message.answer(loc.admn.msgs['error_unrecognized'].format(e))
return

# get information about specified client's configurations
configurations_info = await postgres_dbms.get_configurations_info(client_id)
Expand All @@ -481,8 +482,6 @@ async def check_user_configs(message: Message):
for file_type, date_of_receipt, os, is_chatgpt_available, name, country, city, bandwidth, ping, telegram_file_id in configurations_info:
await internal_functions.send_configuration(message.from_user.id, file_type, date_of_receipt, os, is_chatgpt_available, name, country, city, bandwidth, ping, telegram_file_id)

await message.answer(loc.auth.msgs['configs_rules'], parse_mode='HTML')


@admin_mw.admin_only()
async def get_file_id(message: Message):
Expand Down Expand Up @@ -580,12 +579,13 @@ def register_handlers_admin(dp: Dispatcher):
dp.register_message_handler(show_user_info_sql, state=admin_fsm.UserInfo.ready)
dp.register_message_handler(show_user_config_sql_cm_start, Text(loc.admn.btns['sql_insert_config']))
dp.register_message_handler(show_user_config_sql_cm_start, commands=['sql_config'])
dp.register_message_handler(check_user_configs, state=admin_fsm.ConfigInfo.ready, commands=['check_configs'])
dp.register_message_handler(check_user_configs, commands=['configs'])
dp.register_message_handler(show_user_config_sql, state=admin_fsm.ConfigInfo.ready, content_types=['text', 'photo', 'document'])
dp.register_message_handler(sql_query_fsm_start, Text(loc.admn.btns['sql_query']))
dp.register_message_handler(sql_query_password_verification, state=admin_fsm.SQLQuery.password)
dp.register_message_handler(sql_query_execution, state=admin_fsm.SQLQuery.query)
dp.register_message_handler(show_clients_info, Text(loc.admn.btns['clients_info']))
dp.register_message_handler(show_clients_info, commands=['clients'])
dp.register_message_handler(show_earnings, Text(loc.admn.btns['show_earnings']))
dp.register_message_handler(show_logs, Text(loc.admn.btns['show_logs']))
dp.register_message_handler(show_logs, commands=['logs'])
Expand Down
4 changes: 2 additions & 2 deletions src/localizations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
"messages": {
"reset_fsm_keyboard": "<i>Reset the machine state and keyboard</i>",
"fsm_start": "<i>The machine state is activated</i>",
"admin_kb_info": "To open this menu, use /admin.\b\b Available commands:\n\n/fileid (/fid)\n/sql_user\n/sql_config",
"admin_kb_info": "To open this menu, use /admin.\b\b Available commands:\n\n/fileid (/fid)\n/sql_user\n/sql_config\n/clients\n/configs <i>telegram_id</i> | <i>username</i>",
"go_send_message_menu": "<i>Going to the menu for sending messages to clients</i>",
"message_everyone_info": "Enter the necessary information with the following message, and attach files if necessary!\n\nEnter /perfect to confirm the selection of the last sent message!",
"clients_row_str": "{0}. {1} {2} {3} <code>{4}</code>\n",
Expand All @@ -244,7 +244,7 @@
"sql_insert_client_info": "Forward the message to me and I will output all possible information!",
"cant_read_user": "Unfortunately, I cannot read the user information 😭",
"sql_insert_config_info": "Send me a message in the format (spaces are used instead of line breaks):\n\n<b>client_id</b> - client_username | client_telegram_id\n<b>protocol_id</b> - <code>w</code> (WireGuard) | <code>x</code> (XTLS-Reality) | <code>s</code> (ShadowSocks)\n<b>location_id</b> - <code>n</code> (Netherlands) | <code>l</code> (Latvia) | <code>g</code> (Germany) | <code>u</code> (USA)\n<b>os</b> - <code>Android</code> | <code>IOS</code> | <code>Windows</code> | <code>Linux</code>\n<b>date_of_receipt</b> - date of receipt of the configuration in the format <code>YYYY-MM-DD HH-MI</code>\n<b>link</b> - if instead of a photo or a *.conf file, you need a link for XTLS/SS for PC\n\n<b>Do not forget to attach the file if required!</b>",
"sql_insert_config_check_config_info": "By the way, you can check which configurations are available to the client with the command \n/check_configs <i>telegram_id</i> | <i>username</i>",
"sql_insert_config_check_config_info": "By the way, you can check which configurations are available to the user in the admin menu with the command \n/configs <i>telegram_id</i> | <i>username</i>",
"error_not_enough_flags": "The flags are entered incorrectly, there are too few of them!",
"error_bad_attachment": "You didn't attach the file, or you added the wrong attachment type!",
"error_too_many_flags": "Flags entered incorrectly, there are too many of them!",
Expand Down
4 changes: 2 additions & 2 deletions src/localizations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
"messages": {
"reset_fsm_keyboard": "<i>Сброс машинного состояния и клавиатуры</i>",
"fsm_start": "<i>Активировано машенное состояние</i>",
"admin_kb_info": "Для вызова данного меню используйте /admin.\b\bДоступные команды:\n\n/fileid (/fid)\n/sql_user\n/sql_config",
"admin_kb_info": "Для вызова данного меню используйте /admin.\b\bДоступные команды:\n\n/fileid (/fid)\n/sql_user\n/sql_config\n/clients\n/configs <i>telegram_id</i> | <i>username</i>",
"go_send_message_menu": "<i>Перехожу в меню отправки сообщений пользователям</i>",
"message_everyone_info": "Введите необходимую информацию следующим сообщением, а также приложите файлы при необходимости!\n\nВведите /perfect, чтобы подтвердить выбор последнего отправленного сообщения!",
"clients_row_str": "{0}. {1} {2} {3} <code>{4}</code>\n",
Expand All @@ -244,7 +244,7 @@
"sql_insert_client_info": "Перешлите мне сообщение, и я выведу всю возможную информацию!",
"cant_read_user": "К сожалению, не могу прочитать информацию о пользователе 😭",
"sql_insert_config_info": "Пришлите мне сообщение в формате (вместо переноса строк используются пробелы):\n\n<b>client_id</b> - client_username | client_telegram_id\n<b>protocol_id</b> - <code>w</code> (WireGuard) | <code>x</code> (XTLS-Reality) | <code>s</code> (ShadowSocks)\n<b>location_id</b> - <code>n</code> (Netherlands) | <code>l</code> (Latvia) | <code>g</code> (Germany) | <code>u</code> (USA)\n<b>os</b> - <code>Android</code> | <code>IOS</code> | <code>Windows</code> | <code>Linux</code>\n<b>date_of_receipt</b> - дата получения конфигурации в формате <code>YYYY-MM-DD HH-MI</code>\n<b>link</b> - если вместо фото или файла *.conf нужна ссылка для XTLS/SS для ПК\n\n<b>Не забываем прикрепить файл, если требуется!</b>",
"sql_insert_config_check_config_info": "Кстати, проверить, какие конфигурации доступны пользователю можно командой\n/check_configs <i>telegram_id</i> | <i>username</i>",
"sql_insert_config_check_config_info": "Кстати, проверить, какие конфигурации доступны пользователю можно в админском меню командой\n/configs <i>telegram_id</i> | <i>username</i>",
"error_not_enough_flags": "Флаги введены неверно, их слишком мало!",
"error_bad_attachment": "Вы не приложили файл, либо добавили неверный тип вложения!",
"error_too_many_flags": "Флаги введены неверно, их слишком много!",
Expand Down

0 comments on commit ac66fcc

Please sign in to comment.