InlineKeyboardButton class pyrogram.types.InlineKeyboardButton ads via CarbonBuild your…
- User
InlineKeyboardButton class pyrogram.types.InlineKeyboardButton ads via CarbonBuild your website for just $3.88/mth. More value and performance with Namecheap. ads via Carbon One button of an inline keyboard.
You must use exactly one of the optional fields.
Parameters: text (str) – Label text on the button.
callback_data (str | bytes, optional) – Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes.
url (str, optional) – HTTP url to be opened when button is pressed.
web_app (WebAppInfo, optional) – Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answer_web_app_query(). Available only in private chats between a user and the bot.
login_url (LoginUrl, optional) – An HTTP URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget.
user_id (int, optional) – User id, for links to the user profile.
switch_inline_query (str, optional) – If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot’s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions – in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.
switch_inline_query_current_chat (str, optional) – If set, pressing the button will insert the bot’s username and the specified inline query in the current chat’s input field. Can be empty, in which case only the bot’s username will be inserted.This offers a quick way for the user to open your bot in inline mode in the same chat – good for selecting something from multiple options.
callback_game (CallbackGame, optional) – Description of the game that will be launched when the user presses the button. NOTE: This type of button must always be the first button in the first row.
LoginUrl class pyrogram.types.LoginUrl Represents a parameter of the inline keyboard button used to automatically authorize a user.
Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in.
Parameters: url (str) – An HTTP URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data https://core.telegram.org/widgets/login#receiving-authorization-data.
- Assistant
LoginUrlدر تلگرام یک ویژگی مرتبط با دکمههای کیبورد اینلاین است که به شما اجازه میدهد کاربران را به طور خودکار تأیید هویت کنید. این ویژگی به عنوان یک جایگزین مناسب برای ویجت ورود تلگرام عمل میکند و کاربران تنها با یک کلیک بر روی دکمه و تأیید ورود، میتوانند به سیستم شما وارد شوند.پارامترهای
LoginUrl:-
url (str): این پارامتر URL HTTP است که با دادههای تأیید هویت کاربر به عنوان بخش Query به آن اضافه میشود، وقتی دکمه فشار داده میشود. اگر کاربر از تأیید دادهها امتناع کند، URL اصلی بدون اطلاعات کاربر باز خواهد شد. دادههای اضافه شده دقیقاً همانند توضیحات داوری تأیید دادهها در دریافت دادههای تأیید خواهند بود.
-
- User
چطوری میتونم با جنگو و ویوست از LoginUrl در pyrogram استفاده کنم؟
- Assistant
- User
فقط در ریکوست get میشه استفاده کرد؟ یا در post , put , delete هم کاربرد داره؟
- Assistant
ویژگی
LoginUrlکه در دکمههای کیبورد اینلاین تلگرام استفاده میشود، به طور خاص برای پردازش اطلاعات تأیید هویت کاربران طراحی شده و در واقع فقط در درخواستهایGETکاربرد دارد. زمانی که کاربر بر روی دکمه ورود کلیک میکند، تلگرام یک درخواستGETبه URL معین شده با اطلاعات تأیید هویت کاربر ارسال میکند.دلایل استفاده از GET
-
روند تأیید هویت: زمانیکه کاربر بر روی دکمه کلیک میکند، اطلاعات تأیید هویت کاربران از جمله آیدی، نام و غیره به URL به عنوان پارامترهای کوئری اضافه میشود. این روش از درخواست
GETاستفاده میکند زیرا اطلاعات باید در URL قابل مشاهده برای کاربر باشد. -
سادگی و شفافیت: درخواستهای
GETبرای مقاصد جستجو و بازیابی اطلاعات معمولاً استفاده میشود و مناسب است برای حالتهای احراز هویت که نیاز به نمایش اطلاعات در URL دارند.
محدودیتهای دیگر روشها
-
POST: معمولاً برای ارسال داده به سرور برای پردازش (مانند ذخیرهسازی در پایگاه داده) استفاده میشود. در مورد ، این روش مناسب نیست زیرا اطلاعات باید به طور مستقیم به URL ارسال شود و در این حالت نمیتوان به سادگی دسترسی به آنها داشت.
-
- User
ایا من میتونم تنظیم کنم در LoginUrl چه اطلاعاتی به سمت سرور ارسال بشه؟
- Assistant
در
LoginUrlتلگرام، اطلاعاتی که به سمت سرور شما ارسال میشود به دقت تعریف شده است و شما نمیتوانید تعیین کنید کدام اطلاعات خاص را از سمت کاربر دریافت کنید. تلگرام به طور خودکار اطلاعات مشخصی را به URL شما به عنوان پارامترهای کوئری ارسال میکند، و این اطلاعات شامل موارد زیر است:- id: شناسه منحصر به فرد کاربر.
- first_name: نام کاربر.
- last_name: نام خانوادگی کاربر (در صورت موجود بودن).
- username: نام کاربری کاربر (در صورت موجود بودن).
- photo_url: URL عکس پروفایل کاربر (در صورت موجود بودن).
- auth_date: زمان تأیید هویت به صورت timestamp.
- hash: یک هش برای اعتبارسنجی دادهها که باید بررسی شود.