mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 05:19:41 +00:00
Replace most raw API usage with new location
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import typing
|
||||
|
||||
from .. import utils, hints
|
||||
from ..tl import types, custom
|
||||
from .. import utils, hints, _tl
|
||||
|
||||
|
||||
def build_reply_markup(
|
||||
buttons: 'typing.Optional[hints.MarkupLike]',
|
||||
inline_only: bool = False) -> 'typing.Optional[types.TypeReplyMarkup]':
|
||||
inline_only: bool = False) -> 'typing.Optional[_tl.TypeReplyMarkup]':
|
||||
if buttons is None:
|
||||
return None
|
||||
|
||||
@@ -31,7 +30,7 @@ def build_reply_markup(
|
||||
for row in buttons:
|
||||
current = []
|
||||
for button in row:
|
||||
if isinstance(button, custom.Button):
|
||||
if isinstance(button, _tl.custom.Button):
|
||||
if button.resize is not None:
|
||||
resize = button.resize
|
||||
if button.single_use is not None:
|
||||
@@ -40,10 +39,10 @@ def build_reply_markup(
|
||||
selective = button.selective
|
||||
|
||||
button = button.button
|
||||
elif isinstance(button, custom.MessageButton):
|
||||
elif isinstance(button, _tl.custom.MessageButton):
|
||||
button = button.button
|
||||
|
||||
inline = custom.Button._is_inline(button)
|
||||
inline = _tl.custom.Button._is_inline(button)
|
||||
is_inline |= inline
|
||||
is_normal |= not inline
|
||||
|
||||
@@ -52,14 +51,14 @@ def build_reply_markup(
|
||||
current.append(button)
|
||||
|
||||
if current:
|
||||
rows.append(types.KeyboardButtonRow(current))
|
||||
rows.append(_tl.KeyboardButtonRow(current))
|
||||
|
||||
if inline_only and is_normal:
|
||||
raise ValueError('You cannot use non-inline buttons here')
|
||||
elif is_inline == is_normal and is_normal:
|
||||
raise ValueError('You cannot mix inline with normal buttons')
|
||||
elif is_inline:
|
||||
return types.ReplyInlineMarkup(rows)
|
||||
return _tl.ReplyInlineMarkup(rows)
|
||||
# elif is_normal:
|
||||
return types.ReplyKeyboardMarkup(
|
||||
return _tl.ReplyKeyboardMarkup(
|
||||
rows, resize=resize, single_use=single_use, selective=selective)
|
||||
|
Reference in New Issue
Block a user