mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Quote type hints
Otherwise, sphinx completely butchers the documentation.
This commit is contained in:
parent
c6691dc6a8
commit
d92d989569
|
@ -252,7 +252,7 @@ class AuthMethods(MessageParseMethods, UserMethods):
|
|||
*,
|
||||
password: str = None,
|
||||
bot_token: str = None,
|
||||
phone_code_hash: str = None) -> types.User:
|
||||
phone_code_hash: str = None) -> 'types.User':
|
||||
"""
|
||||
Logs in to Telegram to an existing user or bot account.
|
||||
|
||||
|
@ -327,7 +327,7 @@ class AuthMethods(MessageParseMethods, UserMethods):
|
|||
last_name: str = '',
|
||||
*,
|
||||
phone: str = None,
|
||||
phone_code_hash: str = None) -> types.User:
|
||||
phone_code_hash: str = None) -> 'types.User':
|
||||
"""
|
||||
Signs up to Telegram as a new user account.
|
||||
|
||||
|
@ -406,7 +406,7 @@ class AuthMethods(MessageParseMethods, UserMethods):
|
|||
self: 'TelegramClient',
|
||||
phone: str,
|
||||
*,
|
||||
force_sms: bool = False) -> types.auth.SentCode:
|
||||
force_sms: bool = False) -> 'types.auth.SentCode':
|
||||
"""
|
||||
Sends the Telegram code needed to login to the given phone number.
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ if typing.TYPE_CHECKING:
|
|||
class BotMethods(UserMethods):
|
||||
async def inline_query(
|
||||
self: 'TelegramClient',
|
||||
bot: hints.EntityLike,
|
||||
bot: 'hints.EntityLike',
|
||||
query: str,
|
||||
*,
|
||||
offset: str = None,
|
||||
geo_point: types.GeoPoint = None) -> custom.InlineResults:
|
||||
geo_point: 'types.GeoPoint' = None) -> custom.InlineResults:
|
||||
"""
|
||||
Makes an inline query to the specified bot (e.g. ``@vote New Poll``).
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ if typing.TYPE_CHECKING:
|
|||
class ButtonMethods(UpdateMethods):
|
||||
@staticmethod
|
||||
def build_reply_markup(
|
||||
buttons: typing.Optional[hints.MarkupLike],
|
||||
inline_only: bool = False) -> typing.Optional[types.TypeReplyMarkup]:
|
||||
buttons: 'typing.Optional[hints.MarkupLike]',
|
||||
inline_only: bool = False) -> 'typing.Optional[types.TypeReplyMarkup]':
|
||||
"""
|
||||
Builds a :tl:`ReplyInlineMarkup` or :tl:`ReplyKeyboardMarkup` for
|
||||
the given buttons.
|
||||
|
|
|
@ -280,11 +280,11 @@ class ChatMethods(UserMethods):
|
|||
|
||||
def iter_participants(
|
||||
self: 'TelegramClient',
|
||||
entity: hints.EntityLike,
|
||||
entity: 'hints.EntityLike',
|
||||
limit: float = None,
|
||||
*,
|
||||
search: str = '',
|
||||
filter: types.TypeChannelParticipantsFilter = None,
|
||||
filter: 'types.TypeChannelParticipantsFilter' = None,
|
||||
aggressive: bool = False) -> _ParticipantsIter:
|
||||
"""
|
||||
Iterator over the participants belonging to the specified chat.
|
||||
|
@ -341,7 +341,7 @@ class ChatMethods(UserMethods):
|
|||
async def get_participants(
|
||||
self: 'TelegramClient',
|
||||
*args,
|
||||
**kwargs) -> hints.TotalList:
|
||||
**kwargs) -> 'hints.TotalList':
|
||||
"""
|
||||
Same as `iter_participants`, but returns a
|
||||
`TotalList <telethon.helpers.TotalList>` instead.
|
||||
|
@ -350,13 +350,13 @@ class ChatMethods(UserMethods):
|
|||
|
||||
def iter_admin_log(
|
||||
self: 'TelegramClient',
|
||||
entity: hints.EntityLike,
|
||||
entity: 'hints.EntityLike',
|
||||
limit: float = None,
|
||||
*,
|
||||
max_id: int = 0,
|
||||
min_id: int = 0,
|
||||
search: str = None,
|
||||
admins: hints.EntitiesLike = None,
|
||||
admins: 'hints.EntitiesLike' = None,
|
||||
join: bool = None,
|
||||
leave: bool = None,
|
||||
invite: bool = None,
|
||||
|
@ -485,7 +485,7 @@ class ChatMethods(UserMethods):
|
|||
async def get_admin_log(
|
||||
self: 'TelegramClient',
|
||||
*args,
|
||||
**kwargs) -> hints.TotalList:
|
||||
**kwargs) -> 'hints.TotalList':
|
||||
"""
|
||||
Same as `iter_admin_log`, but returns a ``list`` instead.
|
||||
"""
|
||||
|
@ -493,11 +493,11 @@ class ChatMethods(UserMethods):
|
|||
|
||||
def action(
|
||||
self: 'TelegramClient',
|
||||
entity: hints.EntityLike,
|
||||
action: typing.Union[str, types.TypeSendMessageAction],
|
||||
entity: 'hints.EntityLike',
|
||||
action: 'typing.Union[str, types.TypeSendMessageAction]',
|
||||
*,
|
||||
delay: float = 4,
|
||||
auto_cancel: bool = True) -> typing.Union[_ChatAction, typing.Coroutine]:
|
||||
auto_cancel: bool = True) -> 'typing.Union[_ChatAction, typing.Coroutine]':
|
||||
"""
|
||||
Returns a context-manager object to represent a "chat action".
|
||||
|
||||
|
|
|
@ -105,9 +105,9 @@ class DialogMethods(UserMethods):
|
|||
self: 'TelegramClient',
|
||||
limit: float = None,
|
||||
*,
|
||||
offset_date: hints.DateLike = None,
|
||||
offset_date: 'hints.DateLike' = None,
|
||||
offset_id: int = 0,
|
||||
offset_peer: hints.EntityLike = types.InputPeerEmpty(),
|
||||
offset_peer: 'hints.EntityLike' = types.InputPeerEmpty(),
|
||||
ignore_migrated: bool = False
|
||||
) -> _DialogsIter:
|
||||
"""
|
||||
|
@ -148,7 +148,7 @@ class DialogMethods(UserMethods):
|
|||
ignore_migrated=ignore_migrated
|
||||
)
|
||||
|
||||
async def get_dialogs(self: 'TelegramClient', *args, **kwargs) -> hints.TotalList:
|
||||
async def get_dialogs(self: 'TelegramClient', *args, **kwargs) -> 'hints.TotalList':
|
||||
"""
|
||||
Same as `iter_dialogs`, but returns a
|
||||
`TotalList <telethon.helpers.TotalList>` instead.
|
||||
|
@ -167,7 +167,7 @@ class DialogMethods(UserMethods):
|
|||
# TODO Passing a limit here makes no sense
|
||||
return _DraftsIter(self, None)
|
||||
|
||||
async def get_drafts(self: 'TelegramClient') -> hints.TotalList:
|
||||
async def get_drafts(self: 'TelegramClient') -> 'hints.TotalList':
|
||||
"""
|
||||
Same as :meth:`iter_drafts`, but returns a list instead.
|
||||
"""
|
||||
|
@ -175,7 +175,7 @@ class DialogMethods(UserMethods):
|
|||
|
||||
def conversation(
|
||||
self: 'TelegramClient',
|
||||
entity: hints.EntityLike,
|
||||
entity: 'hints.EntityLike',
|
||||
*,
|
||||
timeout: float = 60,
|
||||
total_timeout: float = None,
|
||||
|
|
|
@ -23,8 +23,8 @@ class DownloadMethods(UserMethods):
|
|||
|
||||
async def download_profile_photo(
|
||||
self: 'TelegramClient',
|
||||
entity: hints.EntityLike,
|
||||
file: hints.FileLike = None,
|
||||
entity: 'hints.EntityLike',
|
||||
file: 'hints.FileLike' = None,
|
||||
*,
|
||||
download_big: bool = True) -> typing.Optional[str]:
|
||||
"""
|
||||
|
@ -128,11 +128,11 @@ class DownloadMethods(UserMethods):
|
|||
|
||||
async def download_media(
|
||||
self: 'TelegramClient',
|
||||
message: hints.MessageLike,
|
||||
file: hints.FileLike = None,
|
||||
message: 'hints.MessageLike',
|
||||
file: 'hints.FileLike' = None,
|
||||
*,
|
||||
thumb: hints.FileLike = None,
|
||||
progress_callback: hints.ProgressCallback = None) -> typing.Optional[str]:
|
||||
thumb: 'hints.FileLike' = None,
|
||||
progress_callback: 'hints.ProgressCallback' = None) -> typing.Optional[str]:
|
||||
"""
|
||||
Downloads the given media from a message object.
|
||||
|
||||
|
@ -208,12 +208,12 @@ class DownloadMethods(UserMethods):
|
|||
|
||||
async def download_file(
|
||||
self: 'TelegramClient',
|
||||
input_location: hints.FileLike,
|
||||
file: hints.OutFileLike = None,
|
||||
input_location: 'hints.FileLike',
|
||||
file: 'hints.OutFileLike' = None,
|
||||
*,
|
||||
part_size_kb: float = None,
|
||||
file_size: int = None,
|
||||
progress_callback: hints.ProgressCallback = None,
|
||||
progress_callback: 'hints.ProgressCallback' = None,
|
||||
dc_id: int = None) -> None:
|
||||
"""
|
||||
Low-level method to download files from their input location.
|
||||
|
|
|
@ -298,21 +298,21 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
|||
|
||||
def iter_messages(
|
||||
self: 'TelegramClient',
|
||||
entity: hints.EntityLike,
|
||||
entity: 'hints.EntityLike',
|
||||
limit: float = None,
|
||||
*,
|
||||
offset_date: hints.DateLike = None,
|
||||
offset_date: 'hints.DateLike' = None,
|
||||
offset_id: int = 0,
|
||||
max_id: int = 0,
|
||||
min_id: int = 0,
|
||||
add_offset: int = 0,
|
||||
search: str = None,
|
||||
filter: typing.Union[types.TypeMessagesFilter, typing.Type[types.TypeMessagesFilter]] = None,
|
||||
from_user: hints.EntityLike = None,
|
||||
filter: 'typing.Union[types.TypeMessagesFilter, typing.Type[types.TypeMessagesFilter]]' = None,
|
||||
from_user: 'hints.EntityLike' = None,
|
||||
wait_time: float = None,
|
||||
ids: typing.Union[int, typing.Sequence[int]] = None,
|
||||
ids: 'typing.Union[int, typing.Sequence[int]]' = None,
|
||||
reverse: bool = False
|
||||
) -> typing.Union[_MessagesIter, _IDsIter]:
|
||||
) -> 'typing.Union[_MessagesIter, _IDsIter]':
|
||||
"""
|
||||
Iterator over the messages for the given chat.
|
||||
|
||||
|
@ -434,7 +434,7 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
|||
search=search
|
||||
)
|
||||
|
||||
async def get_messages(self: 'TelegramClient', *args, **kwargs) -> hints.TotalList:
|
||||
async def get_messages(self: 'TelegramClient', *args, **kwargs) -> 'hints.TotalList':
|
||||
"""
|
||||
Same as `iter_messages`, but returns a
|
||||
`TotalList <telethon.helpers.TotalList>` instead.
|
||||
|
@ -475,17 +475,17 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
|||
|
||||
async def send_message(
|
||||
self: 'TelegramClient',
|
||||
entity: hints.EntityLike,
|
||||
message: hints.MessageLike = '',
|
||||
entity: 'hints.EntityLike',
|
||||
message: 'hints.MessageLike' = '',
|
||||
*,
|
||||
reply_to: typing.Union[int, types.Message] = None,
|
||||
reply_to: 'typing.Union[int, types.Message]' = None,
|
||||
parse_mode: typing.Optional[str] = (),
|
||||
link_preview: bool = True,
|
||||
file: hints.FileLike = None,
|
||||
file: 'hints.FileLike' = None,
|
||||
force_document: bool = False,
|
||||
clear_draft: bool = False,
|
||||
buttons: hints.MarkupLike = None,
|
||||
silent: bool = None) -> types.Message:
|
||||
buttons: 'hints.MarkupLike' = None,
|
||||
silent: bool = None) -> 'types.Message':
|
||||
"""
|
||||
Sends a message to the specified user, chat or channel.
|
||||
|
||||
|
@ -636,12 +636,12 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
|||
|
||||
async def forward_messages(
|
||||
self: 'TelegramClient',
|
||||
entity: hints.EntityLike,
|
||||
messages: typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]],
|
||||
from_peer: hints.EntityLike = None,
|
||||
entity: 'hints.EntityLike',
|
||||
messages: 'typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]]',
|
||||
from_peer: 'hints.EntityLike' = None,
|
||||
*,
|
||||
silent: bool = None,
|
||||
as_album: bool = None) -> typing.Sequence[types.Message]:
|
||||
as_album: bool = None) -> 'typing.Sequence[types.Message]':
|
||||
"""
|
||||
Forwards the given messages to the specified entity.
|
||||
|
||||
|
@ -755,14 +755,14 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
|||
|
||||
async def edit_message(
|
||||
self: 'TelegramClient',
|
||||
entity: typing.Union[hints.EntityLike, types.Message],
|
||||
message: hints.MessageLike = None,
|
||||
entity: 'typing.Union[hints.EntityLike, types.Message]',
|
||||
message: 'hints.MessageLike' = None,
|
||||
text: str = None,
|
||||
*,
|
||||
parse_mode: str = (),
|
||||
link_preview: bool = True,
|
||||
file: hints.FileLike = None,
|
||||
buttons: hints.MarkupLike = None) -> types.Message:
|
||||
file: 'hints.FileLike' = None,
|
||||
buttons: 'hints.MarkupLike' = None) -> 'types.Message':
|
||||
"""
|
||||
Edits the given message to change its text or media.
|
||||
|
||||
|
@ -867,10 +867,10 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
|||
|
||||
async def delete_messages(
|
||||
self: 'TelegramClient',
|
||||
entity: hints.EntityLike,
|
||||
message_ids: typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]],
|
||||
entity: 'hints.EntityLike',
|
||||
message_ids: 'typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]]',
|
||||
*,
|
||||
revoke: bool = True) -> typing.Sequence[types.messages.AffectedMessages]:
|
||||
revoke: bool = True) -> 'typing.Sequence[types.messages.AffectedMessages]':
|
||||
"""
|
||||
Deletes the given messages, optionally "for everyone".
|
||||
|
||||
|
@ -924,8 +924,8 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
|||
|
||||
async def send_read_acknowledge(
|
||||
self: 'TelegramClient',
|
||||
entity: hints.EntityLike,
|
||||
message: typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]] = None,
|
||||
entity: 'hints.EntityLike',
|
||||
message: 'typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]]' = None,
|
||||
*,
|
||||
max_id: int = None,
|
||||
clear_mentions: bool = False) -> bool:
|
||||
|
|
|
@ -164,17 +164,17 @@ class TelegramBaseClient(abc.ABC):
|
|||
|
||||
def __init__(
|
||||
self: 'TelegramClient',
|
||||
session: typing.Union[str, Session],
|
||||
session: 'typing.Union[str, Session]',
|
||||
api_id: int,
|
||||
api_hash: str,
|
||||
*,
|
||||
connection: typing.Type[Connection] = ConnectionTcpFull,
|
||||
connection: 'typing.Type[Connection]' = ConnectionTcpFull,
|
||||
use_ipv6: bool = False,
|
||||
proxy: typing.Union[tuple, dict] = None,
|
||||
timeout: int = 10,
|
||||
request_retries: int = 5,
|
||||
connection_retries: int =5,
|
||||
retry_delay: int =1,
|
||||
retry_delay: int = 1,
|
||||
auto_reconnect: bool = True,
|
||||
sequential_updates: bool = False,
|
||||
flood_sleep_threshold: int = 60,
|
||||
|
|
|
@ -137,7 +137,7 @@ class UpdateMethods(UserMethods):
|
|||
return found
|
||||
|
||||
def list_event_handlers(self: 'TelegramClient')\
|
||||
-> typing.Sequence[typing.Tuple[callable, EventBuilder]]:
|
||||
-> 'typing.Sequence[typing.Tuple[callable, EventBuilder]]':
|
||||
"""
|
||||
Lists all registered event handlers.
|
||||
|
||||
|
|
|
@ -89,23 +89,23 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
|||
|
||||
async def send_file(
|
||||
self: 'TelegramClient',
|
||||
entity: hints.EntityLike,
|
||||
file: hints.FileLike,
|
||||
entity: 'hints.EntityLike',
|
||||
file: 'hints.FileLike',
|
||||
*,
|
||||
caption: str = None,
|
||||
force_document: bool = False,
|
||||
progress_callback: hints.ProgressCallback = None,
|
||||
reply_to: hints.MessageIDLike = None,
|
||||
attributes: typing.Sequence[types.TypeDocumentAttribute] = None,
|
||||
thumb: hints.FileLike = None,
|
||||
progress_callback: 'hints.ProgressCallback' = None,
|
||||
reply_to: 'hints.MessageIDLike' = None,
|
||||
attributes: 'typing.Sequence[types.TypeDocumentAttribute]' = None,
|
||||
thumb: 'hints.FileLike' = None,
|
||||
allow_cache: bool = True,
|
||||
parse_mode: str = (),
|
||||
voice_note: bool = False,
|
||||
video_note: bool = False,
|
||||
buttons: hints.MarkupLike = None,
|
||||
buttons: 'hints.MarkupLike' = None,
|
||||
silent: bool = None,
|
||||
supports_streaming: bool = False,
|
||||
**kwargs) -> types.Message:
|
||||
**kwargs) -> 'types.Message':
|
||||
"""
|
||||
Sends message with the given file to the specified entity.
|
||||
|
||||
|
@ -379,12 +379,12 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
|||
|
||||
async def upload_file(
|
||||
self: 'TelegramClient',
|
||||
file: hints.FileLike,
|
||||
file: 'hints.FileLike',
|
||||
*,
|
||||
part_size_kb: float = None,
|
||||
file_name: str = None,
|
||||
use_cache: type = None,
|
||||
progress_callback: hints.ProgressCallback = None) -> types.TypeInputFile:
|
||||
progress_callback: 'hints.ProgressCallback' = None) -> 'types.TypeInputFile':
|
||||
"""
|
||||
Uploads a file to Telegram's servers, without sending it.
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ class UserMethods(TelegramBaseClient):
|
|||
# region Public methods
|
||||
|
||||
async def get_me(self: 'TelegramClient', input_peer: bool = False) \
|
||||
-> typing.Union[types.User, types.InputPeerUser]:
|
||||
-> 'typing.Union[types.User, types.InputPeerUser]':
|
||||
"""
|
||||
Gets "me", the current :tl:`User` who is logged in.
|
||||
|
||||
|
@ -159,7 +159,7 @@ class UserMethods(TelegramBaseClient):
|
|||
|
||||
async def get_entity(
|
||||
self: 'TelegramClient',
|
||||
entity: hints.EntitiesLike) -> hints.Entity:
|
||||
entity: 'hints.EntitiesLike') -> 'hints.Entity':
|
||||
"""
|
||||
Turns the given entity into a valid Telegram :tl:`User`, :tl:`Chat`
|
||||
or :tl:`Channel`. You can also pass a list or iterable of entities,
|
||||
|
@ -253,7 +253,7 @@ class UserMethods(TelegramBaseClient):
|
|||
|
||||
async def get_input_entity(
|
||||
self: 'TelegramClient',
|
||||
peer: hints.EntityLike) -> types.TypeInputPeer:
|
||||
peer: 'hints.EntityLike') -> 'types.TypeInputPeer':
|
||||
"""
|
||||
Turns the given entity into its input entity version.
|
||||
|
||||
|
@ -380,7 +380,7 @@ class UserMethods(TelegramBaseClient):
|
|||
|
||||
async def get_peer_id(
|
||||
self: 'TelegramClient',
|
||||
peer: hints.EntityLike,
|
||||
peer: 'hints.EntityLike',
|
||||
add_mark: bool = True) -> int:
|
||||
"""
|
||||
Gets the ID for the given entity.
|
||||
|
|
Loading…
Reference in New Issue
Block a user