mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-25 08:06:29 +00:00
538f1e3972
- Pyrogram core is now fully asynchronous - Ditched Python 3.5, welcome 3.6 as minimum version. - Moved all types to pyrogram.types - Turned the Filters class into a module (filters) - Moved all filters to pyrogram.filters - Moved all handlers to pyrogram.handlers - Moved all emoji to pyrogram.emoji - Renamed pyrogram.api to pyrogram.raw - Clock is now synced with server's time - Telegram schema updated to Layer 117 - Greatly improved the TL compiler (proper type-constructor hierarchy) - Added "do not edit" warning in generated files - Crypto parts are executed in a thread pool to avoid blocking the event loop - idle() is now a separate function (it doesn't deal with Client instances) - Async storage, async filters and async progress callback (optional, can be sync too) - Added getpass back, for hidden password inputs
62 lines
2.3 KiB
ReStructuredText
62 lines
2.3 KiB
ReStructuredText
bot_keyboards
|
|
=============
|
|
|
|
This example will show you how to send normal and inline keyboards (as bot).
|
|
|
|
You must log-in as a regular bot in order to send keyboards (use the token from @BotFather).
|
|
Any attempt in sending keyboards with a user account will be simply ignored by the server.
|
|
|
|
send_message() is used as example, but a keyboard can be sent with any other send_* methods,
|
|
like send_audio(), send_document(), send_location(), etc...
|
|
|
|
.. code-block:: python
|
|
|
|
from pyrogram import Client, ReplyKeyboardMarkup, InlineKeyboardMarkup, InlineKeyboardButton
|
|
|
|
# Create a client using your bot token
|
|
app = Client("my_bot", bot_token="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11")
|
|
|
|
with app:
|
|
app.send_message(
|
|
"haskell", # Edit this
|
|
"This is a ReplyKeyboardMarkup example",
|
|
reply_markup=ReplyKeyboardMarkup(
|
|
[
|
|
["A", "B", "C", "D"], # First row
|
|
["E", "F", "G"], # Second row
|
|
["H", "I"], # Third row
|
|
["J"] # Fourth row
|
|
],
|
|
resize_keyboard=True # Make the keyboard smaller
|
|
)
|
|
)
|
|
|
|
app.send_message(
|
|
"haskell", # Edit this
|
|
"This is a InlineKeyboardMarkup example",
|
|
reply_markup=InlineKeyboardMarkup(
|
|
[
|
|
[ # First row
|
|
InlineKeyboardButton( # Generates a callback query when pressed
|
|
"Button",
|
|
callback_data="data"
|
|
),
|
|
InlineKeyboardButton( # Opens a web URL
|
|
"URL",
|
|
url="https://docs.pyrogram.org"
|
|
),
|
|
],
|
|
[ # Second row
|
|
InlineKeyboardButton( # Opens the inline interface
|
|
"Choose chat",
|
|
switch_inline_query="pyrogram"
|
|
),
|
|
InlineKeyboardButton( # Opens the inline interface in the current chat
|
|
"Inline here",
|
|
switch_inline_query_current_chat="pyrogram"
|
|
)
|
|
]
|
|
]
|
|
)
|
|
)
|