main
Сергей Ванюшкин 2024-02-15 01:19:29 +03:00
parent 062caa416d
commit 9dba5b26f3
2 changed files with 39 additions and 1 deletions

View File

@ -9,7 +9,7 @@ from aiogram.filters import CommandStart
from aiogram.types import Message
from aiogram.utils.markdown import hbold
from tg_bot.handlers.lesson_one import router as router_one
from tg_bot.handlers.lesson_two import router as router_one
TOKEN: str = getenv('BOT_TOKEN') or 'Your TG_BOT token'

View File

@ -0,0 +1,38 @@
from aiogram import F, Router
from aiogram.filters import Command
from aiogram.fsm.context import FSMContext
from aiogram.fsm.state import State, StatesGroup
from aiogram.types import Message
from aiogram.utils.markdown import hbold
router = Router()
greatings = ['привет', 'добрый день', 'добрый вечер', 'доброе утро', 'здравствуйте']
class OrderReverse(StatesGroup):
string = State()
@router.message(Command('reverse'))
async def reverse_request(message: Message, state: FSMContext):
await state.set_state(OrderReverse.string)
await message.answer(
text='Введите строку для разворота',
)
@router.message(OrderReverse.string, F.text)
async def reversing(message: Message, state: FSMContext):
string = message.text
if string is not None:
string = string[::-1]
await message.answer(
text=f'Ваша строка наоборот:\n{string}',
)
await state.clear()
@router.message(F.text.func(lambda m: m.lower() in greatings))
async def greating(message: Message):
await message.answer(f'Здравствуй, {hbold(message.from_user.first_name)}')