Fix Keyboard location

This commit is contained in:
Jahongir Qurbonov 2024-08-21 15:38:23 +05:00
parent bd28f8900d
commit 6548db63a7
8 changed files with 20 additions and 24 deletions

View File

@ -36,6 +36,7 @@ from ..types import (
Group,
InFileLike,
InlineResult,
KeyboardType,
LoginToken,
Message,
OutFileLike,
@ -45,7 +46,6 @@ from ..types import (
RecentAction,
User,
)
from ..types.buttons import KeyboardType
from .auth import (
bot_sign_in,
check_password,

View File

@ -13,6 +13,7 @@ from ..types import (
AsyncList,
File,
InFileLike,
KeyboardType,
Message,
OutFileLike,
OutWrapper,
@ -22,7 +23,6 @@ from ..types import (
parse_message,
try_get_url_path,
)
from ..types.buttons import KeyboardType
if TYPE_CHECKING:
from .client import Client

View File

@ -8,6 +8,7 @@ from ...session import ChannelRef, PeerRef
from ...tl import abcs, functions, types
from ..types import (
AsyncList,
KeyboardType,
Message,
Peer,
build_chat_map,
@ -15,7 +16,6 @@ from ..types import (
parse_message,
peer_id,
)
from ..types.buttons import KeyboardType
if TYPE_CHECKING:
from .client import Client

View File

@ -14,6 +14,7 @@ from .file import (
try_get_url_path,
)
from .inline_result import InlineResult
from .keyboard import InlineKeyboard, Keyboard, KeyboardType
from .login_token import LoginToken
from .message import (
Message,
@ -60,4 +61,7 @@ __all__ = [
"Participant",
"PasswordToken",
"RecentAction",
"Keyboard",
"InlineKeyboard",
"KeyboardType",
]

View File

@ -7,7 +7,6 @@ from ....tl import abcs, types
from .button import Button
from .callback import Callback
from .inline_button import InlineButton
from .keyboard import InlineKeyboard, Keyboard, KeyboardType
from .request_geo_location import RequestGeoLocation
from .request_phone import RequestPhone
from .request_poll import RequestPoll
@ -19,11 +18,6 @@ if TYPE_CHECKING:
from ..message import Message
def as_concrete_row(row: abcs.KeyboardButtonRow) -> types.KeyboardButtonRow:
assert isinstance(row, types.KeyboardButtonRow)
return row
def create_button(message: Message, raw: abcs.KeyboardButton) -> Button:
"""
Create a custom button from a Telegram button.
@ -80,9 +74,6 @@ __all__ = [
"Button",
"Callback",
"InlineButton",
"InlineKeyboard",
"Keyboard",
"KeyboardType",
"RequestGeoLocation",
"RequestPhone",
"RequestPoll",

View File

@ -1,7 +1,7 @@
from typing import Optional, TypeAlias
from ....tl import abcs, types
from .button import Button
from ...tl import abcs, types
from .buttons.button import Button
def _build_keyboard_rows(

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import datetime
import time
from typing import TYPE_CHECKING, Any, Optional, Self, Sequence
from typing import TYPE_CHECKING, Any, Optional, Self, Sequence, cast
from ...session import PeerRef
from ...tl import abcs, types
@ -12,8 +12,9 @@ from ..parsers import (
parse_html_message,
parse_markdown_message,
)
from .buttons import Button, KeyboardType, as_concrete_row, create_button
from .buttons import Button, create_button
from .file import File
from .keyboard import KeyboardType
from .meta import NoPublicConstructor
from .peer import Peer, expand_peer, peer_id
@ -476,8 +477,11 @@ class Message(metaclass=NoPublicConstructor):
return None
return [
[create_button(self, button) for button in row.buttons]
for row in map(as_concrete_row, markup.rows)
[
create_button(self, button)
for button in cast(types.KeyboardButtonRow, row).buttons
]
for row in markup.rows
]
@property

View File

@ -13,7 +13,9 @@ from .._impl.client.types import (
Draft,
File,
Group,
InlineKeyboard,
InlineResult,
Keyboard,
LoginToken,
Message,
Participant,
@ -22,12 +24,7 @@ from .._impl.client.types import (
RecentAction,
User,
)
from .._impl.client.types.buttons import (
Button,
InlineButton,
InlineKeyboard,
Keyboard,
)
from .._impl.client.types.buttons import Button, InlineButton
from .._impl.session import ChannelRef, GroupRef, PeerRef, UserRef
__all__ = [