mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-06 15:14:52 +00:00
Use str or bytes for callback_data and CallbackQuery.data (#241)
This commit is contained in:
parent
313bf8952f
commit
8dd99a8683
2 changed files with 4 additions and 3 deletions
|
|
@ -79,7 +79,7 @@ class CallbackQuery(PyrogramType, Update):
|
||||||
self.chat_instance = chat_instance
|
self.chat_instance = chat_instance
|
||||||
self.message = message
|
self.message = message
|
||||||
self.inline_message_id = inline_message_id
|
self.inline_message_id = inline_message_id
|
||||||
self.data = data
|
self.data: str = str(data, "utf-8")
|
||||||
self.game_short_name = game_short_name
|
self.game_short_name = game_short_name
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from pyrogram.api.types import (
|
from pyrogram.api.types import (
|
||||||
KeyboardButtonUrl, KeyboardButtonCallback,
|
KeyboardButtonUrl, KeyboardButtonCallback,
|
||||||
|
|
@ -61,7 +62,7 @@ class InlineKeyboardButton(PyrogramType):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
text: str,
|
text: str,
|
||||||
callback_data: bytes = None,
|
callback_data: Union[str, bytes] = None,
|
||||||
url: str = None,
|
url: str = None,
|
||||||
switch_inline_query: str = None,
|
switch_inline_query: str = None,
|
||||||
switch_inline_query_current_chat: str = None,
|
switch_inline_query_current_chat: str = None,
|
||||||
|
|
@ -71,7 +72,7 @@ class InlineKeyboardButton(PyrogramType):
|
||||||
|
|
||||||
self.text = str(text)
|
self.text = str(text)
|
||||||
self.url = url
|
self.url = url
|
||||||
self.callback_data = callback_data
|
self.callback_data = bytes(callback_data, "utf-8") if isinstance(callback_data, str) else callback_data
|
||||||
self.switch_inline_query = switch_inline_query
|
self.switch_inline_query = switch_inline_query
|
||||||
self.switch_inline_query_current_chat = switch_inline_query_current_chat
|
self.switch_inline_query_current_chat = switch_inline_query_current_chat
|
||||||
self.callback_game = callback_game
|
self.callback_game = callback_game
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue