Клавиатура в Телеграм Ботах - Inline Reply и Builder на AIOGRAM 3.4 | 4 УРОК

$ sudo teach IT ⚙️
27 Feb 202415:38

Summary

TLDRThis video tutorial guides viewers through creating Telegram bots using the aiogram library, focusing on the development of two types of keyboards: Reply and Inline. The script explains the differences between these keyboards, their functions, and how to implement them in a bot. It demonstrates creating a Reply keyboard with dynamic buttons and an Inline keyboard with URL links. The tutorial also touches on using the Builder for generating keyboards dynamically based on data, such as a list of car brands, and emphasizes the importance of the 'Reply markup' method for attaching keyboards to messages.

Takeaways

  • 😀 The lesson focuses on creating Telegram bots using aiogram, specifically discussing the creation of Reply and Inline keyboards.
  • 🔑 There are two types of keyboards in Telegram bots: Reply (appears at the bottom instead of the usual phone keyboard) and Inline (buttons attached to a message).
  • 🛠️ The script demonstrates creating a Reply keyboard by importing necessary modules and constructing a keyboard with buttons programmatically.
  • 📲 The script also shows how to add a Reply keyboard to a message handler in the bot using the 'Reply markup' argument.
  • 🔗 Inline keyboards are different in that they do not send content to the chat but perform actions or request additional data like location or contact.
  • 💡 Inline keyboards can also open links or web applications embedded in Telegram, offering interactive elements within the chat.
  • 🛠️ The script explains how to create Inline keyboards by adding URL or other required elements and using the 'Inline Keyboard' notation.
  • 🔧 The lesson touches on using the 'Builder' feature for creating dynamic keyboards based on data, such as a list of car brands from a database.
  • 🔄 The script demonstrates how to use the 'Keyboard Builder' to dynamically generate keyboard buttons from a list of items, such as car models.
  • 📝 The lesson concludes with a reminder to always include additional parameters like 'resize' or 'Input Field placeholder' when creating keyboards for better user experience.

Q & A

  • What are the two types of keyboards mentioned in the script for Telegram bots?

    -The two types of keyboards mentioned are 'Reply' keyboards and 'Inline' keyboards. 'Reply' keyboards appear at the bottom of the screen instead of the usual phone keyboard, while 'Inline' keyboards are buttons attached to a message.

  • How do 'Reply' and 'Inline' keyboards differ in functionality?

    -'Reply' keyboards send their content directly into the chat when a button is pressed, whereas 'Inline' keyboards do not send anything to the chat but perform actions such as sending a request to a server or opening a link or web application within Telegram.

  • What is the purpose of using 'Inline' keyboards in Telegram bots?

    -The purpose of using 'Inline' keyboards is to perform actions without sending content directly to the chat, such as sending a callback to the server, opening a link, or interacting with web applications without the user leaving the chat interface.

  • How can one create a 'Reply' keyboard in a Telegram bot using aiogram?

    -To create a 'Reply' keyboard in aiogram, one must import 'ReplyKeyboardMarkup' and 'KeyboardButton' from 'aiogram.types', create a 'Keyboard' object, add 'KeyboardButton' objects to it, and then set it as the 'reply_markup' in the message.

  • What is the significance of the 'resize_keyboard' parameter in 'Reply' keyboards?

    -The 'resize_keyboard' parameter is used to allow the user to resize the keyboard on their device. It can be set to 'True' to enable resizing or 'False' to keep the keyboard at a fixed size.

  • How can one add a placeholder to a 'Reply' keyboard button?

    -A placeholder can be added to a 'Reply' keyboard button using the 'input_field_placeholder' parameter, which sets the placeholder text that appears on the button.

  • What is the difference between creating a 'Reply' keyboard and an 'Inline' keyboard in aiogram?

    -The main difference is that 'Inline' keyboards require a URL or a callback to be associated with each button, whereas 'Reply' keyboards do not. 'Inline' keyboards are created using 'InlineKeyboardButton' and are attached to a message using the 'reply_markup' parameter with 'InlineKeyboardMarkup'.

  • Why might one use a 'Builder' when creating 'Inline' keyboards?

    -A 'Builder' is used when the content of the keyboard is dynamic, such as when it's based on data retrieved from a database. It allows for the creation of a keyboard with a variable number of buttons without hardcoding the buttons in the code.

  • How can one create an 'Inline' keyboard dynamically using a 'Builder' in aiogram?

    -To create an 'Inline' keyboard dynamically, one can use 'InlineKeyboardBuilder' and loop through the data to add 'InlineKeyboardButton' objects with the necessary URL or callback. The 'build' method is then called to finalize the keyboard, which can be set as the 'reply_markup'.

  • What additional parameters can be set for 'Inline' keyboard buttons?

    -Additional parameters for 'Inline' keyboard buttons include 'url' for opening a link, 'callback_data' for sending data to the server, 'switch_inline_query' for prompting the user to switch to another inline query, and 'web_app' for opening a web application.

  • How can one edit an existing 'Inline' keyboard in a Telegram bot?

    -An existing 'Inline' keyboard can be edited using methods like 'edit_message_reply_markup' with the updated 'InlineKeyboardMarkup'. This allows for dynamic changes to the keyboard based on user interactions or other events.

Outlines

00:00

🤖 Introduction to Telegram Bots and Keyboards

This paragraph introduces the fourth lesson on creating Telegram bots using aiogram, focusing on the creation of two types of keyboards: Reply (rep) and Inline. It explains the visual and functional differences between these keyboards, using an AI-powered bot as an example. The bot showcases a message with both Inline and Reply buttons, demonstrating their distinct functionalities. The lesson then transitions into creating these keyboards, starting with Reply keyboards, which are simpler to create. It guides through the process of creating a keyboard using aiogram, including importing necessary modules and defining the keyboard and buttons within Python code.

05:02

🔧 Customizing Reply Keyboards and Exploring Inline Keyboards

The second paragraph delves into customizing Reply keyboards, discussing the use of additional arguments such as 'resize_keyboard' and 'input_field_placeholder' to modify the keyboard's appearance and behavior. It contrasts the use of large buttons in certain bots, like gaming bots, with the more typical use in catalog or shopping bots. The paragraph then moves on to creating Inline keyboards, emphasizing the necessity of including a URL or other required elements. It also touches on the limitations of attaching multiple keyboards to a single message and introduces the concept of using handlers to manage keyboard interactions.

10:04

🛠 Building Dynamic Keyboards with a Builder

This section introduces the concept of using a 'Builder' for creating dynamic keyboards based on data, such as a list of car brands retrieved from a database. It demonstrates how to use the 'Keyboard' and 'KeyboardButton' classes from aiogram to dynamically generate keyboard buttons based on the data. The paragraph explains the process of creating an asynchronous function to handle dynamic data, looping through a list of items (like car brands) and adding them as buttons to the keyboard. It also covers the importance of using 'reply_markup' when attaching the keyboard to a message and provides a practical example of how to implement this in a Telegram bot.

15:05

🌐 Closing Remarks and Learning Resources

The final paragraph serves as a conclusion to the lesson, inviting viewers to explore further learning resources on Python, aiogram, and SQL through courses available on the provided website. It emphasizes the author's commitment to supporting learners through exclusive chat and answering questions. The paragraph ends with a call to action for viewers to like, subscribe, and leave comments for further engagement and to stay tuned for the next lesson.

Mindmap

Keywords

💡Telegram Bot

A Telegram Bot is an automated program that operates within the Telegram messaging platform. It can send messages, respond to commands, and perform various tasks. In the video, the creation of a Telegram bot is the central theme, focusing on how to develop it using the aiogram library to interact with users through different types of keyboards.

💡aiogram

Aiogram is a Python library used for building Telegram bots. It simplifies the process of interacting with the Telegram Bot API. The video script describes how to use aiogram to create a bot with different keyboard functionalities, demonstrating its practical application in bot development.

💡Inline Keyboard

An Inline Keyboard in Telegram bots is a type of keyboard that appears directly under a message and allows users to interact with the bot through buttons. These buttons can be used to trigger different actions or to navigate through the bot's features. The script explains how to create an Inline Keyboard and attach it to a message, which is a key aspect of user interaction in bots.

💡Reply Keyboard

A Reply Keyboard, also known as a 'rep' keyboard, is a type of keyboard that appears at the bottom of the screen, replacing the standard phone keyboard when a user is interacting with a bot. The script mentions creating a Reply Keyboard with specific buttons, which is used to send predefined messages to the chat.

💡Callback

In the context of Telegram bots, a callback refers to a function or action that is triggered when a user interacts with an Inline Keyboard button. The script discusses how a callback is sent to the server when an Inline button is pressed, and the server then processes this callback to perform a specific action or return a response.

💡Inline Keyboard Button

Inline Keyboard Buttons are the individual buttons within an Inline Keyboard. They can be configured to perform various actions such as opening a link, displaying a callback, or requesting user data like location or contact information. The video script provides an example of creating Inline Keyboard Buttons and attaching them to a message.

💡Builder

The Builder in the context of the video refers to a tool or method used to dynamically create keyboards based on data, such as a list of items from a database. The script explains how to use a Builder to create a Reply Keyboard dynamically, which is useful when the bot needs to present a variable set of options to the user.

💡Keyboard Button

A Keyboard Button is an element of both Reply and Inline Keyboards used in Telegram bots. It can be configured with text and additional parameters to define its appearance and behavior. The script describes the process of creating Keyboard Buttons and adding them to a keyboard within a bot.

💡Web Application

In the script, a Web Application refers to an external application that can be accessed through a link or URL. Inline Keyboard Buttons can be set up to open web applications, allowing users to interact with external services directly from the bot. This is mentioned as one of the functionalities that can be achieved with Inline Keyboard Buttons.

💡Resize Keyboard

The term 'Resize Keyboard' in the script refers to an option that can be set when creating a Reply Keyboard to control the size of the keyboard. The script mentions using the 'resize_keyboard' parameter to make the keyboard smaller, which affects the layout and user experience on mobile devices.

💡Input Field Placeholder

An Input Field Placeholder is a feature used in Reply Keyboards to provide a hint or example text within an input field. The script explains how to use the 'input_field_placeholder' parameter to set a placeholder text, which can guide users on what to input, enhancing the user interface of the bot.

Highlights

Introduction to creating Telegram bots using aiogram, focusing on the fourth lesson about creating keyboards.

Explanation of two types of keyboards in Telegram bots: Reply keyboards and Inline keyboards.

Demonstration of a bot with AI showcasing both types of keyboards with their visual and functional differences.

Tutorial on creating a Reply keyboard using aiogram by importing necessary modules and creating a keyboard layout.

Adding buttons to the Reply keyboard and adjusting their placement in rows.

Integration of the Reply keyboard into a bot's handlers and setting up the Reply markup.

Testing the bot to see the created Reply keyboard in action.

Addressing the issue of large button sizes in Telegram and how to adjust them using the 'resize_keyboard' parameter.

Introduction to Inline keyboards and the requirement of adding a URL or callback to the buttons.

Creating an Inline keyboard by adding URL links to the buttons and setting up the Inline keyboard markup.

Limitation of attaching only one keyboard per message and the need to send multiple messages for different keyboards.

Exploring the use of the Builder for creating dynamic keyboards based on data from a database.

Tutorial on using the Builder to create an Inline keyboard dynamically with car brands as an example.

Explanation of how to handle asynchronous functions when creating keyboards with Builders.

Testing the dynamic Inline keyboard with car brands and demonstrating its real-time update feature.

Highlighting the importance of the 'markup' parameter when creating keyboards in aiogram.

Promotion of the author's courses on Python, aiogram, and SQL for further learning.

Encouragement for viewers to like, subscribe, and comment on the video for more useful content.

Transcripts

play00:00

Добро пожаловать на четвёртый урок по

play00:01

созданию Telegram ботов на aiogram Темой

play00:04

сегодняшнего урока будет создание

play00:06

клавиатуры Inline rep а также через

play00:09

Builder в Telegram ботах существует два

play00:11

вида клавиатуры одна из них выходит в

play00:14

самом низу вместо обычной телефонной

play00:17

клавиатуры их называют repl а второй вид

play00:19

- это кнопки которые цепляются под

play00:21

сообщение они называются Inline У меня

play00:24

есть вот такой вот бот с искусственным

play00:26

интеллектом и на его примере мы видим

play00:28

оба вида кно

play00:30

у этого сообщения есть своя клавиатура в

play00:33

которой две Илай кнопки а также снизу

play00:36

есть несколько rep кнопок кроме

play00:38

визуального отличия они также работают

play00:40

по-разному и выполняют разные функции

play00:42

например при нажатии rep кнопки её

play00:44

содержимое отправляется в чат Чего

play00:47

например не скажешь про Inline который

play00:50

ничего не отправляет в чат и выполняет

play00:52

какие-либо действия также ре могут

play00:54

запрашивать локацию Контакт или какие-то

play00:57

другие данные а при нажатии на Inline в

play01:00

примере данного бота на сервер

play01:02

отправляется какой-то запрос Например я

play01:05

нажимаю настройки моделей и отправляется

play01:07

callback на сервер и мы получаем ответ

play01:10

то есть это какая-то функция срабатывает

play01:12

соответственно этот коллбэк пользователь

play01:14

не видит он видит только результат а

play01:16

callback видит только сервер на Inline

play01:18

мы можем открывать какую-либо ссылку

play01:20

либо веб-приложение встроенное в

play01:22

Telegram Давайте же приступим к созданию

play01:25

этих клавиатур И начнём с repl потому

play01:27

что их проще всего создавать и обра

play01:30

для это в па App я создам новый файл и

play01:34

назову его хотел назвать

play01:37

keyb теперь из I types я должен

play01:41

импортировать

play01:43

rep Keyboard Mar и Keyboard Button

play01:48

сначала Я создаю клавиатуру То есть это

play01:51

Keyboard Mar а потом в эту клавиатуру Я

play01:55

добавляю какие-то кнопки здесь у меня

play01:58

есть тако Key argument как Keyboard и мы

play02:02

видим что этот Keyboard должен содержать

play02:06

в себе список внутри которого есть ещё

play02:09

один список и внутри этого списка

play02:11

находится Keyboard Button соответственно

play02:13

мы создаём список и внутрь этого списка

play02:16

добавляем ещё один список и Keyboard

play02:18

Button что у нас запрашивает Keyboard

play02:21

Button он просит у нас текст а всё

play02:24

остальное необязательно давайте ему

play02:26

передадим туда текст Пусть это будет

play02:28

каталог и Давайте ещё один Keyboard

play02:31

Button например Это

play02:34

корзина рядом с корзиной в одном ряду Я

play02:36

хочу сделать ещё один keyb Button Мы

play02:39

видим что я его делаю в этом же списке Я

play02:41

хочу сделать контакты то есть Какой

play02:43

вывод если у нас один список это один

play02:47

ряд то когда я добавляю в один список

play02:50

два Keyboard Button соответственно Я в

play02:53

один ряд добавляю две кнопки и у меня

play02:56

получается два ряда Это первый ряд это

play02:58

второй ряд в об сложности три кнопки всё

play03:01

это всё хранится в переменной Main

play03:03

Теперь давайте перейдём в handlers и

play03:06

здесь в handlers Я

play03:08

импортируют как это будет выглядеть я

play03:11

импортируют к файлу run.py From App kbs

play03:16

Давайте не From сделаем а импорт сразу

play03:19

ипор

play03:21

skb то есть я Укоротил это название и

play03:25

импортировала сразу все переменные

play03:26

вообще всё что есть в этом файле потому

play03:29

что оно только здесь у нас и будет

play03:31

использоваться в другом месте не

play03:32

используется и на команду Start я

play03:34

добавлю ещё один keyword argument

play03:37

называется Reply markup и Вот видите

play03:39

Reply markup принимает либо Inline либо

play03:43

Reply либо Remove Вот ещё есть Force

play03:46

Reply например Давайте подставим сюда KB

play03:49

то Main называется у меня переменная да

play03:53

Я обратился получается к вот этому файлу

play03:55

keyboards и к переменной Main внутри

play03:58

этого файла вот оно у нас и Давайте же

play04:00

теперь запустим посмотрим что у нас

play04:03

получилось Всё нужно сохранить для этого

play04:06

и я запускаю терминал по

play04:08

новой запускаю виртуальное окружение

play04:12

scripts acate и запускаю скрипт Pon

play04:15

run.py И теперь мы переходим в бот

play04:19

Давайте посмотрим вот он у нас тест бот

play04:22

я

play04:24

напишу и видим как раз таки вот эти вот

play04:27

три кнопки которые я создал посмотрим на

play04:30

аналогию здесь как это у нас выглядит

play04:33

вот у нас получается каталог стоит

play04:35

первый первый список соответственно вот

play04:37

он первый список и внутри второго списка

play04:41

две кнопки корзины и контакты

play04:43

соответственно Вот они в одном ряду

play04:44

корзины и контакты но кнопки слишком

play04:47

большие это сразу видно А почему они

play04:50

такие в телеграме непонятно Павел Дуров

play04:52

сделал это чтобы мы просто видели

play04:54

отличия А если смотреть через телефон то

play04:57

размер этой клавиатуры подстраивается

play04:59

под размер клавиатуры вашего телефона

play05:02

поэтому на телефоне она будет ещё больше

play05:04

И как это исправить если вам такие

play05:06

большие кнопки не нравятся я могу

play05:07

привести пример где такие кнопки большие

play05:09

используются например вот такой вот есть

play05:11

бот Game если я не ошибаюсь то вот мы

play05:15

видим здесь видите такие большие кнопки

play05:17

и для такого игрового бота на самом деле

play05:19

очень даже красиво и удобно на телефоне

play05:21

выглядит ещё прикольнее Вот Но если бот

play05:25

Вот такой вот с каталогом с корзиной но

play05:27

я думаю нет смысла делать такие большие

play05:29

кнопки Поэтому вот этого класса repl

play05:33

Keyboard markup видите есть

play05:35

дополнительно ещё keyword arguments да

play05:38

это

play05:40

получается аргументы как ключ с ключом

play05:43

Вот и например есть ciz Keyboard вот

play05:47

есть Input Field placeholder One Time -

play05:49

это когда на один раз используется и она

play05:51

потом скрывается Вот давайте

play05:52

воспользуемся вот этим resz Skateboard и

play05:58

холдером

play06:05

И вот так вот я добавил res keb это

play06:08

значит он меняется до минимального

play06:11

значения до минимального размера а Input

play06:13

Field placeholder это ну если вы знаете

play06:16

что такое да фронтенд то Вот вместо

play06:20

Write mess будет написано то что я

play06:22

передал выберите пункт Меню дате тепер

play06:25

Пустим Бота я нажимаю ctr C стрелку

play06:28

вверх и здесь пишу опять старт и вот на

play06:34

команду Старт Мы видим что теперь кнопки

play06:35

маленькие теперь не кажется как будто

play06:37

слишком маленькие на самом деле менять

play06:39

размер больше никак не получится и вот

play06:41

мы видим все эти кнопки Если добавлять

play06:43

ещё то будет ещё красивее так они

play06:45

выглядят так они создаются вот здесь вот

play06:47

мы видим написано выберите пункт меню

play06:50

вот это обычные ре кнопки теперь давайте

play06:53

рассмотрим то Как создаются Как выглядят

play06:56

in кнопки и вот например хочу прицепить

play06:59

их опять же к этому же сообщению Давайте

play07:28

попробуем

play07:34

прошу заметить что когда мы создаём

play07:36

inine клавиатуру то мы обязательно

play07:39

должны вписать что-то дополнительное то

play07:41

есть мы не можем оставить просто текст

play07:44

Мы обязательно должны добавить ещё

play07:46

что-то в моём случае я добавил сюда URL

play07:49

и URL всегда должен начинаться либо с

play07:52

http либо

play07:54

https Если вы напишете что-то другое то

play07:57

будет выходить ошибка

play08:00

Вот и по сути смысл того как они

play08:03

создаются они абсолютно идентичны с то

play08:06

есть тоже список в списке Вот просто мы

play08:09

обязательно должны дописывать URL и

play08:11

здесь мы вместо пишем слово in и здесь к

play08:15

keb добавляем слово Inline Keyboard вот

play08:18

и всё А такие значения как resize или

play08:21

Input Field placeholder он не принимает

play08:23

вот мы видим что он принимает

play08:25

только вот и всё у многих новичков тоже

play08:29

как вот к одному сообщению прицепить

play08:31

например две клавиатуры на самом деле

play08:34

это невозможно мы только к одному

play08:36

сообщению можем прицепить одну

play08:38

клавиатуру поэтому я вместо Main Теперь

play08:40

сюда поце Сен вот таким вот образом и

play08:44

Давайте также протестируем здесь есть

play08:47

дополнительные методы Как там Edit Mar

play08:50

ещё что-то вот Но это немножко другая

play08:52

тема И на самом деле таким образом две

play08:54

клавиатуры не вывести нужно отправлять

play08:56

два сообщения я пишу снова и вот мы

play08:59

видим здесь Как раз-таки эту кнопку

play09:02

которая будет вести на мой Youtube канал

play09:04

Также можно любую другую ссылку

play09:06

поставить вот или посмотреть что

play09:08

принимает Button вот он может открывать

play09:11

ссылку отправлять callback мы рассмотрим

play09:15

Что такое callback на следующем уроке

play09:17

потому что это тоже отдельная тема нужно

play09:19

их обрабатывать с помощью хендлера также

play09:21

он может открывать Web Application

play09:23

отправлять какой-то URL для того чтобы

play09:26

авторизоваться на каком-то сайте через

play09:28

Telegram Вот это для Илай мода

play09:32

дополнительные параметры так сказать или

play09:34

игр вот мы можем отправлять ивой чтобы

play09:37

человек заплатил за какой-то счёт вот в

play09:40

общем-то это возможности Лайна вот

play09:42

Keyboard Button Мы видим что он может

play09:44

запрашивать юзера чат контакт локацию

play09:48

опрос также открывать веб-приложение Вот

play09:51

и запрашивать в общем-то пользователя

play09:54

вот такие вот у них отличия так они

play09:56

используются и цепляются опять же

play09:59

обязательно к сообщению с помощью метода

play10:01

Reply markup также у многих возникает

play10:03

вопрос Что такое Builder Как

play10:06

пользоваться билдером Зачем он нужен

play10:08

Бывает такое что вы делаете запрос из

play10:10

базы данных и получаете скажем набор

play10:13

какой-то Да вот список и там название

play10:16

автомобилей какие автомобили у вас есть

play10:18

в каталоге например а Tesla мы добавим

play10:22

ещё Mercedes и для любителей BMW BMW

play10:26

добавим Да и здесь напишем переменную

play10:29

Cars например и вот предположим что Вы

play10:32

получили такой ответ от базы данных да

play10:34

достали все марки автомобиле которые у

play10:36

вас есть и они могут быть всегда разные

play10:39

То есть это не такая статичная

play10:40

клавиатура и вы не хотите постоянно

play10:43

менять эти значения через код что мы

play10:45

делаем мы в этом случае пользуемся

play10:47

билдером давайте я импортируют

play10:51

inl клавиатуру с помощью билде и как

play10:54

сделать вот из iog у мы должны и я вот

play11:00

так вот напишу bu не здесь такого нету

play11:03

Дописать надо

play11:04

keyb bu и вот мы видим keyb

play11:08

bu Key bu и in Key bu keb butt я

play11:13

импортировать не буду потому что вот он

play11:15

у меня уже есть это одно и тоже И теперь

play11:17

я делаю функцию давайте я сразу сделаю

play11:20

асинхронную функцию покажу как работать

play11:21

сразу с асинхронными потому что обычную

play11:24

функцию смысла делать

play11:27

неде

play11:29

Cars так будет называться моя функция

play11:32

она ничего не принимает я не буду

play11:33

дописывать что она возвращает думаю

play11:36

аннотации каждый сможет сделать сам По

play11:38

надобности дальше Я создаю точно также

play11:42

переменную например Keyboard равно пусть

play11:46

для начала будет rep Keyboard Builder

play11:48

дальше я делаю цикл for Cars in Cars

play11:52

Многие могут сказать напиши сюда там As

play11:55

Да вот так вот но в этом тоже нет смысла

play11:58

это вызовет только дополнительную ошибку

play12:00

дальше Я обращаюсь к этой же переменной

play12:02

Keyboard и его методу Add он не

play12:05

асинхронный вот я просто пишу сюда Add и

play12:08

подставляю Keyboard Button и

play12:11

соответственно текст у меня равняется

play12:13

Car Да это как раз таки строчка с

play12:15

названием автомобиля и всё в самом конце

play12:18

Я возвращаю Return

play12:21

Keyboard я могу Дописать сюда adj то

play12:25

есть это в том случае если я хочу

play12:28

отредактировать размер этой клавиатуры

play12:31

размер имеется в виду не res keyb True а

play12:36

то сколько кнопок будет в одном ряду Вот

play12:40

я сказал что в одном ряду у меня будет

play12:41

по две кнопки и в самом конце

play12:43

обязательно всегда нужно просто

play12:45

дописывать S markup Вот и всё теперь мы

play12:48

переходим сюда в хендлер и у нас эта

play12:51

функция так ещё асинхронная как её

play12:54

вызвать ничего сложного на самом деле в

play12:56

этом нету A KB и у нас есть Inline Cars

play13:00

функция и обязательно в конце скобки

play13:02

потому что мы эту функцию вызываем вот

play13:04

нам нужно должна вернуться вот эта

play13:06

корутина с э марка пом всё тоже

play13:11

сохраняем Давайте

play13:13

перезапустили захожу в батан пишу Старт

play13:16

вот и что мы видим вот у нас вышли вот

play13:18

эти автомобили Tesla Mercedes BMW то

play13:20

есть основываясь Да из вот этого списка

play13:23

мы сделали клавиатуру и вместо этого

play13:26

списка у вас может быть запрос в базу

play13:28

данных Где вы получаете какой-то

play13:29

результат его итерируемый

play13:58

например URL ссылку Да

play14:02

https пока что я подставляю YouTube

play14:05

ссылку на следующем уроке мы будем уже

play14:07

подставлять колбеки вот колбеки будут

play14:10

более полезны для нас и также

play14:12

перезапуска и проверяем Давайте

play14:14

посмотрим точно также прописываю Старт

play14:17

после запуска и вот мы видим что у нас

play14:19

все эти кнопки тоже создались Tesla

play14:21

Mercedes BMW если я вот сюда вот в

play14:24

список а добавлю ещё какую-то марку

play14:27

например Porsche

play14:29

то у меня тоже сразу же Оно отобразится

play14:32

даже мне не нужно А нет я должен

play14:34

перезапустить потому что это же

play14:36

переменная вот также прописываю старт и

play14:39

вот она у меня уже появляется Почему

play14:41

здесь по две кнопки Tesla Mercedes и BMW

play14:44

Porsche вот так вот по два стоят Потому

play14:46

что здесь adj я написал два то есть в

play14:48

одном ряду у меня находятся две кнопки

play14:51

Вот вот и всё Mar всегда нужно

play14:53

дописывать в конце и опять же Напоминаю

play14:55

что не может быть только тек обязательно

play14:59

либо URL либо Web Application В общем

play15:02

что угодно из этого должно быть

play15:04

обязательно дополнительно вот и всё Если

play15:07

вы хотите изучать Python детальнее iog

play15:10

или SQL У нас есть как бесплатные так и

play15:13

платные курсы на сайте suda ti.com всех

play15:17

жду это авторские курсы с полной

play15:19

поддержкой вы получаете дополнительно

play15:22

доступ к чату эксклюзивному где я

play15:25

обязательно отвечу на все ваши вопросы

play15:28

Спасибо за просмотр буду рад вашим

play15:30

лайкам Не забудьте подписаться на канал

play15:32

чтобы не потерять полезный контент и

play15:33

оставить своё мнение в комментариях Жду

play15:35

вас на следующем уроке

Rate This

5.0 / 5 (0 votes)

Related Tags
Telegram BotsaiogramInline KeyboardsReply KeyboardsPython ProgrammingBot DevelopmentCoding TutorialChatbot CreationWeb ApplicationProgramming Course