From cc4a850134e393dace1149a86bfb101b111f3474 Mon Sep 17 00:00:00 2001 From: Udith Amasura Date: Thu, 23 Dec 2021 22:26:22 +0530 Subject: [PATCH] Make bot_username optional for LoginUrl (#817) * make bot username optional * Update login_url.py * Update login_url.py Co-authored-by: Dan <14043624+delivrance@users.noreply.github.com> --- pyrogram/types/bots_and_keyboards/inline_keyboard_button.py | 2 +- pyrogram/types/bots_and_keyboards/login_url.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py b/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py index 84d70642..0e4bb40b 100644 --- a/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py +++ b/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py @@ -147,7 +147,7 @@ class InlineKeyboardButton(Object): if self.login_url is not None: return self.login_url.write( text=self.text, - bot=await client.resolve_peer(self.login_url.bot_username) + bot=await client.resolve_peer(self.login_url.bot_username or "self") ) if self.switch_inline_query is not None: diff --git a/pyrogram/types/bots_and_keyboards/login_url.py b/pyrogram/types/bots_and_keyboards/login_url.py index 21c7a45d..52ef8dc8 100644 --- a/pyrogram/types/bots_and_keyboards/login_url.py +++ b/pyrogram/types/bots_and_keyboards/login_url.py @@ -31,7 +31,8 @@ class LoginUrl(Object): 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. + be opened. The data added is the same as described in + `Receiving authorization data `. **NOTE**: You **must** always check the hash of the received data to verify the authentication and the integrity of the data as described in @@ -42,7 +43,7 @@ class LoginUrl(Object): bot_username (``str``, *optional*): Username of a bot, which will be used for user authorization. - See `Setting up `_ a bot for more details. + See `Setting up a bot `_ for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See `Linking your domain to the bot `_