-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Rxyalxrd/master
new structure, project initiation
- Loading branch information
Showing
5 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from aiogram import F, Router | ||
from aiogram.filters import CommandStart | ||
from aiogram.types import Message, CallbackQuery | ||
|
||
from bot.keyborads import ( | ||
main_keyboard, company_information_keyboard, | ||
inline_products_and_services | ||
) | ||
|
||
|
||
router = Router() | ||
|
||
|
||
@router.message(CommandStart()) | ||
async def cmd_start(message: Message) -> None: | ||
"""Приветствие пользователя.""" | ||
|
||
await message.answer( | ||
'Здравстуйте! Я ваш виртуальный помошник.' | ||
'Как я могу помочь вам сегодня?', | ||
reply_markup=main_keyboard | ||
) | ||
|
||
|
||
@router.message(F.text == 'Посмотреть портфолио.') | ||
async def view_profile(message: Message) -> None: | ||
"""Портфолио компании.""" | ||
|
||
await message.answer( | ||
'Вот ссылка на на наше портофолио: [здесь url]. ' | ||
'Хотите узнать больше о конкретных проектах ' | ||
'или услугах?' | ||
) | ||
|
||
|
||
@router.message(F.text == 'Получить информацию о компании.') | ||
async def get_information_about_company(message: Message) -> None: | ||
"""Информация о компнии.""" | ||
|
||
await message.answer( | ||
'Вот несколько вариантов информации о нашей ' | ||
'компании. Что именно вас интересует? ', | ||
reply_markup=company_information_keyboard | ||
) | ||
|
||
|
||
@router.message(F.text == 'Узнать о продуктах и услугах.') | ||
async def get_information_about_products_and_services(message: Message) -> None: | ||
"""Информация о продуктах и услугах.""" | ||
|
||
await message.answer( | ||
'Мы предлагаем следующие продукты и услуги.' | ||
'Какой из низ вас интересует?', | ||
reply_markup=await inline_products_and_services() | ||
) | ||
|
||
|
||
@router.callback_query(lambda call: call == 'previous_choice') | ||
def previous_choice(callback_query: CallbackQuery) -> None: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from aiogram.types import ( | ||
ReplyKeyboardMarkup, KeyboardButton, | ||
InlineKeyboardMarkup, InlineKeyboardButton, | ||
) | ||
from aiogram.utils.keyboard import InlineKeyboardBuilder | ||
|
||
# кнопку вернуться назад можно вынести отдельно, чтобы не дублировать код | ||
|
||
PRODUCTS_AND_SERVICES = [ | ||
'Разработка сайтов', 'Создание порталов', | ||
'Разработка мобильных приложений', 'Консультация по КИОСК365', | ||
'"НБП ЕЖА"', 'Хостинг', | ||
] # моделирую результат запроса из бд | ||
|
||
main_keyboard = ReplyKeyboardMarkup( | ||
keyboard=[ | ||
[KeyboardButton(text='Посмотреть портфолио.')], | ||
[KeyboardButton(text='Получить информацию о компании.')], | ||
[KeyboardButton(text='Узнать о продуктах и услугах.')], | ||
[KeyboardButton(text='Получить техническую поддержку.'),], | ||
[KeyboardButton(text='Связаться с менеджером.')], | ||
], | ||
resize_keyboard=True, | ||
one_time_keyboard=False, | ||
input_field_placeholder='Выберите пункт меню.' | ||
) | ||
|
||
company_information_keyboard = InlineKeyboardMarkup( | ||
inline_keyboard=[ | ||
[ | ||
InlineKeyboardButton( | ||
text='Презентация компании.', | ||
url='https://www.visme.co/ru/powerpoint-online/' # тут ссылка на презентацию, ткунл рандомную | ||
) | ||
], | ||
[ | ||
InlineKeyboardButton( | ||
text='Карточка компании.', | ||
url='https://github.com/Rxyalxrd' # тут будет карточка компании, пока моя) | ||
) | ||
], | ||
[ | ||
InlineKeyboardButton( | ||
text='Назад к основным вариантам.', | ||
callback_data='previous_choice' | ||
) | ||
] | ||
] | ||
) | ||
|
||
|
||
async def inline_products_and_services(): # тут будем брать данные из бд | ||
"""Инлайн клавиатура для продуктов и услуг.""" # аннатацию тоже не пишу пока | ||
|
||
keyboard = InlineKeyboardBuilder() | ||
|
||
for index, product_and_service in enumerate(PRODUCTS_AND_SERVICES): | ||
# callback_data = f"service_{index}" | ||
keyboard.add(InlineKeyboardButton( | ||
text=product_and_service, | ||
callback_data=f'service_{index}' | ||
)) | ||
|
||
keyboard.add( | ||
InlineKeyboardButton( | ||
text='Назад к основным вариантам.', | ||
callback_data='previous_choice' | ||
) | ||
) | ||
|
||
return keyboard.adjust(1).as_markup() | ||
|
||
|
||
company_portfolio_choice = InlineKeyboardMarkup( | ||
inline_keyboard=[ | ||
[InlineKeyboardButton(text='Да', '''TODO: бот отвечает и выводит проектов''')], | ||
[ | ||
InlineKeyboardButton( | ||
text='Назад к основным вариантам.', | ||
callback_data='previous_choice' | ||
) | ||
] | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
import logging | ||
import asyncio | ||
import sys | ||
|
||
from aiogram import Bot, Dispatcher | ||
from dotenv import load_dotenv | ||
|
||
from bot.handlers import router | ||
|
||
|
||
load_dotenv() | ||
|
||
|
||
bot = Bot(token=os.getenv('BOT_TOKEN')) | ||
dispatcher = Dispatcher() | ||
|
||
|
||
async def main() -> None: | ||
"""Запуск SCID бота.""" | ||
|
||
if os.getenv('BOT_TOKEN') is None: # нарушает solid - принцип ед. наследсвенности | ||
sys.exit('Отсутсвуют необходимые токены.') | ||
|
||
dispatcher.include_router(router) | ||
await dispatcher.start_polling(bot) | ||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
try: | ||
asyncio.run(main()) | ||
except KeyboardInterrupt: | ||
print('Exit') |
File renamed without changes.