diff --git a/docs/index.rst b/docs/index.rst index a923cab1..2d5bfdd0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,29 +1,27 @@ -.. include:: ../README.rst +import logging +from aiogram import Bot, Dispatcher, types +from aiogram.utils import executor +from aiogram.types import ReplyKeyboardMarkup, KeyboardButton +TOKEN = 7537770028:AAEBMd-n9Nce8EjHy6c6sFKSucpYKXrBU08 +bot = Bot(token=TOKEN) +dp = Dispatcher(bot) +tap_button = KeyboardButton('Тап!') +keyboard = ReplyKeyboardMarkup(resize_keyboard=True).add(tap_button) +/start +@dp.message_handler(commands=['start']) +async def send_welcome(message: types.Message): + await message.answer("Привет! Нажимай на кнопку 'Тап!' чтобы тапать.", reply_markup=keyboard) -Simple usage ------------- +# Обработчик нажатия на кнопку 'Тап!' +@dp.message_handler(lambda message: message.text == 'Тап!') +async def handle_tap(message: types.Message): + await message.answer("Ты тапнул!") -.. literalinclude:: ../examples/echo_bot.py +# Обработчик любых текстовых сообщений +@dp.message_handler(content_types=types.ContentTypes.TEXT) +async def handle_text(message: types.Message): + await message.answer("Просто тапай!") - -Usage without dispatcher ------------------------- - -Just only interact with Bot API, without handling events - -.. literalinclude:: ../examples/without_dispatcher.py - - -Contents -======== - -.. toctree:: - :maxdepth: 3 - - install - migration_2_to_3 - api/index - dispatcher/index - utils/index - changelog - contributing +# Запуск бота +if __name__ == '__main__': + executor.start_polling(dp, skip_updates=True)