Update index.rst

This commit is contained in:
Kovpei 2024-09-18 13:24:15 +02:00 committed by GitHub
parent a76fb42ba0
commit 73ab7c3c46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)