Visitar URL original
Use str or bytes for callback_data and CallbackQuery.data (#241) · alistvt/pyrogram@d30cad1 · GitHub
Skip to content

Commit d30cad1

Browse files
JosXadelivrance
authored andcommitted
Use str or bytes for callback_data and CallbackQuery.data (pyrogram#241)
1 parent cc9bc56 commit d30cad1

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎pyrogram/client/types/bots/callback_query.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __init__(
7979
self.chat_instance = chat_instance
8080
self.message = message
8181
self.inline_message_id = inline_message_id
82-
self.data = data
82+
self.data = str(data, "utf-8")
8383
self.game_short_name = game_short_name
8484

8585
@staticmethod

‎pyrogram/client/types/bots/inline_keyboard_button.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
from typing import Union
20+
1921
from pyrogram.api.types import (
2022
KeyboardButtonUrl, KeyboardButtonCallback,
2123
KeyboardButtonSwitchInline, KeyboardButtonGame
@@ -61,7 +63,7 @@ class InlineKeyboardButton(PyrogramType):
6163
def __init__(
6264
self,
6365
text: str,
64-
callback_data: bytes = None,
66+
callback_data: Union[str, bytes] = None,
6567
url: str = None,
6668
switch_inline_query: str = None,
6769
switch_inline_query_current_chat: str = None,
@@ -71,7 +73,7 @@ def __init__(
7173

7274
self.text = str(text)
7375
self.url = url
74-
self.callback_data = callback_data
76+
self.callback_data = bytes(callback_data, "utf-8") if isinstance(callback_data, str) else callback_data
7577
self.switch_inline_query = switch_inline_query
7678
self.switch_inline_query_current_chat = switch_inline_query_current_chat
7779
self.callback_game = callback_game

0 commit comments

Comments
 (0)