mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-27 08:19:47 +03:00
Fix Keyboard location
This commit is contained in:
parent
bd28f8900d
commit
6548db63a7
|
@ -36,6 +36,7 @@ from ..types import (
|
||||||
Group,
|
Group,
|
||||||
InFileLike,
|
InFileLike,
|
||||||
InlineResult,
|
InlineResult,
|
||||||
|
KeyboardType,
|
||||||
LoginToken,
|
LoginToken,
|
||||||
Message,
|
Message,
|
||||||
OutFileLike,
|
OutFileLike,
|
||||||
|
@ -45,7 +46,6 @@ from ..types import (
|
||||||
RecentAction,
|
RecentAction,
|
||||||
User,
|
User,
|
||||||
)
|
)
|
||||||
from ..types.buttons import KeyboardType
|
|
||||||
from .auth import (
|
from .auth import (
|
||||||
bot_sign_in,
|
bot_sign_in,
|
||||||
check_password,
|
check_password,
|
||||||
|
|
|
@ -13,6 +13,7 @@ from ..types import (
|
||||||
AsyncList,
|
AsyncList,
|
||||||
File,
|
File,
|
||||||
InFileLike,
|
InFileLike,
|
||||||
|
KeyboardType,
|
||||||
Message,
|
Message,
|
||||||
OutFileLike,
|
OutFileLike,
|
||||||
OutWrapper,
|
OutWrapper,
|
||||||
|
@ -22,7 +23,6 @@ from ..types import (
|
||||||
parse_message,
|
parse_message,
|
||||||
try_get_url_path,
|
try_get_url_path,
|
||||||
)
|
)
|
||||||
from ..types.buttons import KeyboardType
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .client import Client
|
from .client import Client
|
||||||
|
|
|
@ -8,6 +8,7 @@ from ...session import ChannelRef, PeerRef
|
||||||
from ...tl import abcs, functions, types
|
from ...tl import abcs, functions, types
|
||||||
from ..types import (
|
from ..types import (
|
||||||
AsyncList,
|
AsyncList,
|
||||||
|
KeyboardType,
|
||||||
Message,
|
Message,
|
||||||
Peer,
|
Peer,
|
||||||
build_chat_map,
|
build_chat_map,
|
||||||
|
@ -15,7 +16,6 @@ from ..types import (
|
||||||
parse_message,
|
parse_message,
|
||||||
peer_id,
|
peer_id,
|
||||||
)
|
)
|
||||||
from ..types.buttons import KeyboardType
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .client import Client
|
from .client import Client
|
||||||
|
|
|
@ -14,6 +14,7 @@ from .file import (
|
||||||
try_get_url_path,
|
try_get_url_path,
|
||||||
)
|
)
|
||||||
from .inline_result import InlineResult
|
from .inline_result import InlineResult
|
||||||
|
from .keyboard import InlineKeyboard, Keyboard, KeyboardType
|
||||||
from .login_token import LoginToken
|
from .login_token import LoginToken
|
||||||
from .message import (
|
from .message import (
|
||||||
Message,
|
Message,
|
||||||
|
@ -60,4 +61,7 @@ __all__ = [
|
||||||
"Participant",
|
"Participant",
|
||||||
"PasswordToken",
|
"PasswordToken",
|
||||||
"RecentAction",
|
"RecentAction",
|
||||||
|
"Keyboard",
|
||||||
|
"InlineKeyboard",
|
||||||
|
"KeyboardType",
|
||||||
]
|
]
|
||||||
|
|
|
@ -7,7 +7,6 @@ from ....tl import abcs, types
|
||||||
from .button import Button
|
from .button import Button
|
||||||
from .callback import Callback
|
from .callback import Callback
|
||||||
from .inline_button import InlineButton
|
from .inline_button import InlineButton
|
||||||
from .keyboard import InlineKeyboard, Keyboard, KeyboardType
|
|
||||||
from .request_geo_location import RequestGeoLocation
|
from .request_geo_location import RequestGeoLocation
|
||||||
from .request_phone import RequestPhone
|
from .request_phone import RequestPhone
|
||||||
from .request_poll import RequestPoll
|
from .request_poll import RequestPoll
|
||||||
|
@ -19,11 +18,6 @@ if TYPE_CHECKING:
|
||||||
from ..message import Message
|
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:
|
def create_button(message: Message, raw: abcs.KeyboardButton) -> Button:
|
||||||
"""
|
"""
|
||||||
Create a custom button from a Telegram button.
|
Create a custom button from a Telegram button.
|
||||||
|
@ -80,9 +74,6 @@ __all__ = [
|
||||||
"Button",
|
"Button",
|
||||||
"Callback",
|
"Callback",
|
||||||
"InlineButton",
|
"InlineButton",
|
||||||
"InlineKeyboard",
|
|
||||||
"Keyboard",
|
|
||||||
"KeyboardType",
|
|
||||||
"RequestGeoLocation",
|
"RequestGeoLocation",
|
||||||
"RequestPhone",
|
"RequestPhone",
|
||||||
"RequestPoll",
|
"RequestPoll",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from typing import Optional, TypeAlias
|
from typing import Optional, TypeAlias
|
||||||
|
|
||||||
from ....tl import abcs, types
|
from ...tl import abcs, types
|
||||||
from .button import Button
|
from .buttons.button import Button
|
||||||
|
|
||||||
|
|
||||||
def _build_keyboard_rows(
|
def _build_keyboard_rows(
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
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 ...session import PeerRef
|
||||||
from ...tl import abcs, types
|
from ...tl import abcs, types
|
||||||
|
@ -12,8 +12,9 @@ from ..parsers import (
|
||||||
parse_html_message,
|
parse_html_message,
|
||||||
parse_markdown_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 .file import File
|
||||||
|
from .keyboard import KeyboardType
|
||||||
from .meta import NoPublicConstructor
|
from .meta import NoPublicConstructor
|
||||||
from .peer import Peer, expand_peer, peer_id
|
from .peer import Peer, expand_peer, peer_id
|
||||||
|
|
||||||
|
@ -476,8 +477,11 @@ class Message(metaclass=NoPublicConstructor):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return [
|
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
|
@property
|
||||||
|
|
|
@ -13,7 +13,9 @@ from .._impl.client.types import (
|
||||||
Draft,
|
Draft,
|
||||||
File,
|
File,
|
||||||
Group,
|
Group,
|
||||||
|
InlineKeyboard,
|
||||||
InlineResult,
|
InlineResult,
|
||||||
|
Keyboard,
|
||||||
LoginToken,
|
LoginToken,
|
||||||
Message,
|
Message,
|
||||||
Participant,
|
Participant,
|
||||||
|
@ -22,12 +24,7 @@ from .._impl.client.types import (
|
||||||
RecentAction,
|
RecentAction,
|
||||||
User,
|
User,
|
||||||
)
|
)
|
||||||
from .._impl.client.types.buttons import (
|
from .._impl.client.types.buttons import Button, InlineButton
|
||||||
Button,
|
|
||||||
InlineButton,
|
|
||||||
InlineKeyboard,
|
|
||||||
Keyboard,
|
|
||||||
)
|
|
||||||
from .._impl.session import ChannelRef, GroupRef, PeerRef, UserRef
|
from .._impl.session import ChannelRef, GroupRef, PeerRef, UserRef
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user