Skip to content

Commit

Permalink
feat(bot): add instructions texts
Browse files Browse the repository at this point in the history
  • Loading branch information
exmanka committed Jan 17, 2024
1 parent 379c9db commit 93b574f
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 86 deletions.
1 change: 1 addition & 0 deletions src/handlers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ async def send_configuration(message: Message, state: FSMContext):
# send message to client, admin and finish FSM for sending configurations
await bot.send_message(telegram_id, loc.auth.msgs['config_was_received'], parse_mode='HTML')
await internal_functions.send_configuration(telegram_id, file_type, date_of_receipt, os, is_chatgpt_available, name, country, city, bandwidth, ping, telegram_file_id)
await bot.send_message(telegram_id, loc.auth.msgs['configs_rules'], parse_mode='HTML')
await message.reply(loc.admn.msgs['config_was_sent'].format(file_type), parse_mode='HTML')
await state.finish()

Expand Down
1 change: 1 addition & 0 deletions src/handlers/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async def command_start(message: Message, state: FSMContext = None):
if state:
await state.finish()
await message.answer(loc.other.msgs['already_registered'], reply_markup=user_authorized_kb.menu)
await message.answer(loc.auth.msgs['configs_rules'], parse_mode='HTML')


def register_handlers_other(dp: Dispatcher):
Expand Down
30 changes: 26 additions & 4 deletions src/handlers/user_authorized.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import random
from decimal import Decimal
from aiogram import Dispatcher
from aiogram.types import Message, CallbackQuery
from aiogram.types import Message, CallbackQuery, MediaGroup
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters import Text
from aiogram.utils.exceptions import MessageToDeleteNotFound
Expand Down Expand Up @@ -302,7 +302,7 @@ async def account_configurations_request_chatgpt(message: Message, state: FSMCon
await internal_functions.send_configuration_request_to_admin({'fullname': message.from_user.full_name, 'username': message.from_user.username,
'id': message.from_user.id}, data._data, is_new_client=False)

await message.answer(loc.auth.msgs['wait_for_admin'], reply_markup=user_authorized_kb.config)
await message.answer(loc.auth.msgs['wait_for_admin'], parse_mode='HTML', reply_markup=user_authorized_kb.config)
await message.answer(loc.auth.msgs['i_wanna_sleep'])
await state.set_state(user_authorized_fsm.AccountMenu.configs)

Expand Down Expand Up @@ -574,14 +574,36 @@ async def account_promo_info(message: Message):
async def configuration_instruction(call: CallbackQuery):
"""Send message with instruction for configuration specified by inline button."""
configuration_protocol_name, configuration_os = call.data.split('--')
await call.message.reply(loc.internal.msgs['instructions'][configuration_protocol_name.lower()][configuration_os.lower()])

# answer without photos
# await call.message.reply(loc.auth.msgs['instructions'][configuration_protocol_name.lower()][configuration_os.lower()],
# parse_mode='HTML', disable_web_page_preview=True)

# get objects from localization
instruction_text = loc.auth.msgs['instructions'][configuration_protocol_name.lower()][configuration_os.lower()]
instruction_images_list = loc.auth.tfids['instructions'][configuration_protocol_name.lower()][configuration_os.lower()]

# use media group builder in aiogram 3.x.x
# create media group with multiple photos and caption as instruction
media_group = MediaGroup()

# add first image to media group with caption and parse_mode to display caption in instruction
media_group.attach_photo(instruction_images_list[0], caption=instruction_text, parse_mode='HTML')

# add all other photos to media group
if len(instruction_images_list) > 1:
for telegram_file_id in instruction_images_list[1:]:
media_group.attach_photo(telegram_file_id)

# send media group to client
await call.message.reply_media_group(media_group)
await call.answer()


@user_mw.authorized_only()
async def show_project_rules(message: Message):
"""Send message with information about project rules."""
await message.answer(loc.auth.msgs['rules'], parse_mode='HTML')
await message.answer_photo(loc.auth.tfids['rules'], caption=loc.auth.msgs['rules'], parse_mode='HTML')


@user_mw.authorized_only()
Expand Down
4 changes: 3 additions & 1 deletion src/keyboards/other_kb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
from src.services import localization as loc


faq_inline = InlineKeyboardMarkup().add(InlineKeyboardButton(loc.other.btns['faq_inline'], callback_data=loc.other.btns['faq_inline_callback']))
faq_inline = InlineKeyboardMarkup().\
add(InlineKeyboardButton(loc.other.btns['faq_inline'], callback_data=loc.other.btns['faq_inline_callback'])).\
add(InlineKeyboardButton(loc.other.btns['tg_channel_inline'], url=loc.other.btns['tg_channel_inline_url']))
Loading

0 comments on commit 93b574f

Please sign in to comment.