From 943ad892f7a2926b4bf2f851992155d343cb8247 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Mon, 13 Sep 2021 21:00:31 +0200 Subject: [PATCH] Address remaining uses of the Request suffix with raw API --- telethon/_client/chats.py | 2 +- telethon/_client/messages.py | 4 ++-- telethon/_client/telegrambaseclient.py | 4 ++-- telethon/_client/telegramclient.py | 8 +++---- telethon/_client/updates.py | 2 +- telethon/_client/uploads.py | 2 +- telethon/_client/users.py | 2 +- telethon/_crypto/cdndecrypter.py | 2 +- telethon/_network/mtprotostate.py | 2 +- telethon/events/callbackquery.py | 2 +- telethon/types/_custom/draft.py | 2 +- telethon/types/_custom/messagebutton.py | 2 +- telethon_examples/payment.py | 30 ++++++++++++------------- 13 files changed, 32 insertions(+), 32 deletions(-) diff --git a/telethon/_client/chats.py b/telethon/_client/chats.py index 7eb6a2a1..21fb02e5 100644 --- a/telethon/_client/chats.py +++ b/telethon/_client/chats.py @@ -524,7 +524,7 @@ def action( raise ValueError('Cannot use {} as action'.format(action)) if isinstance(action, _tl.SendMessageCancelAction): - # ``SetTypingRequest.resolve`` will get input peer of ``entity``. + # ``SetTyping.resolve`` will get input peer of ``entity``. return self(_tl.fn.messages.SetTyping( entity, _tl.SendMessageCancelAction())) diff --git a/telethon/_client/messages.py b/telethon/_client/messages.py index 3b63d35b..b7bbf518 100644 --- a/telethon/_client/messages.py +++ b/telethon/_client/messages.py @@ -244,7 +244,7 @@ class _MessagesIter(requestiter.RequestIter): # We want to skip the one we already have self.request.offset_id += 1 - if isinstance(self.request, _tl.fn.messages.SearchRequest): + if isinstance(self.request, _tl.fn.messages.Search): # Unlike getHistory and searchGlobal that use *offset* date, # this is *max* date. This means that doing a search in reverse # will break it. Since it's not really needed once we're going @@ -254,7 +254,7 @@ class _MessagesIter(requestiter.RequestIter): # getHistory, searchGlobal and getReplies call it offset_date self.request.offset_date = last_message.date - if isinstance(self.request, _tl.fn.messages.SearchGlobalRequest): + if isinstance(self.request, _tl.fn.messages.SearchGlobal): if last_message.input_chat: self.request.offset_peer = last_message.input_chat else: diff --git a/telethon/_client/telegrambaseclient.py b/telethon/_client/telegrambaseclient.py index 0ac127f0..d8d333f0 100644 --- a/telethon/_client/telegrambaseclient.py +++ b/telethon/_client/telegrambaseclient.py @@ -197,7 +197,7 @@ def init( _tl.InputClientProxy(*connection.address_info(proxy)) # Used on connection. Capture the variables in a lambda since - # exporting clients need to create this InvokeWithLayerRequest. + # exporting clients need to create this InvokeWithLayer. system = platform.uname() if system.machine in ('x86_64', 'AMD64'): @@ -559,7 +559,7 @@ async def _get_cdn_client(self: 'TelegramClient', cdn_redirect): # This will make use of the new RSA keys for this specific CDN. # - # We won't be calling GetConfigRequest because it's only called + # We won't be calling GetConfig because it's only called # when needed by ._get_dc, and also it's static so it's likely # set already. Avoid invoking non-CDN methods by not syncing updates. client.connect(_sync_updates=False) diff --git a/telethon/_client/telegramclient.py b/telethon/_client/telegramclient.py index 5c84a990..1a12b122 100644 --- a/telethon/_client/telegramclient.py +++ b/telethon/_client/telegramclient.py @@ -173,7 +173,7 @@ class TelegramClient: Returns a :ref:`telethon-client` which calls methods behind a takeout session. It does so by creating a proxy object over the current client through - which making requests will use :tl:`InvokeWithTakeoutRequest` to wrap + which making requests will use :tl:`InvokeWithTakeout` to wrap them. In other words, returns the current client modified so that requests are done as a takeout: @@ -764,7 +764,7 @@ class TelegramClient: This has no effect if a ``filter`` is given. Yields - The :tl:`User` objects returned by :tl:`GetParticipantsRequest` + The :tl:`User` objects returned by :tl:`GetParticipants` with an additional ``.participant`` attribute which is the matched :tl:`ChannelParticipant` type for channels/megagroups or :tl:`ChatParticipants` for normal chats. @@ -2067,7 +2067,7 @@ class TelegramClient: .. note:: - Telegram's flood wait limit for :tl:`GetHistoryRequest` seems to + Telegram's flood wait limit for :tl:`GetHistory` seems to be around 30 seconds per 10 requests, therefore a sleep of 1 second is the default for this limit (or above). @@ -2125,7 +2125,7 @@ class TelegramClient: wait_time (`int`): Wait time (in seconds) between different - :tl:`GetHistoryRequest`. Use this parameter to avoid hitting + :tl:`GetHistory`. Use this parameter to avoid hitting the ``FloodWaitError`` as needed. If left to `None`, it will default to 1 second only if the limit is higher than 3000. diff --git a/telethon/_client/updates.py b/telethon/_client/updates.py index 9d1e205c..93e8a9bc 100644 --- a/telethon/_client/updates.py +++ b/telethon/_client/updates.py @@ -257,7 +257,7 @@ async def _dispatch_update(self: 'TelegramClient', update, others, channel_id, p # we should be okay (no flood waits) even if more occur. pass except ValueError: - # There is a chance that GetFullChannelRequest and GetDifferenceRequest + # There is a chance that GetFullChannel and GetDifference # inside the _get_difference() function will end up with # ValueError("Request was unsuccessful N time(s)") for whatever reasons. pass diff --git a/telethon/_client/uploads.py b/telethon/_client/uploads.py index fb5bfc0c..244c5b59 100644 --- a/telethon/_client/uploads.py +++ b/telethon/_client/uploads.py @@ -341,7 +341,7 @@ async def upload_file( # what Telegram wants. hash_md5.update(part) - # The SavePartRequest is different depending on whether + # The SavePart is different depending on whether # the file is too large or not (over or less than 10MB) if is_big: request = _tl.fn.upload.SaveBigFilePart( diff --git a/telethon/_client/users.py b/telethon/_client/users.py index 9bf18faf..f3393196 100644 --- a/telethon/_client/users.py +++ b/telethon/_client/users.py @@ -208,7 +208,7 @@ async def get_entity( chats = lists[helpers._EntityType.CHAT] channels = lists[helpers._EntityType.CHANNEL] if users: - # GetUsersRequest has a limit of 200 per call + # GetUsers has a limit of 200 per call tmp = [] while users: curr, users = users[:200], users[200:] diff --git a/telethon/_crypto/cdndecrypter.py b/telethon/_crypto/cdndecrypter.py index 8347a561..73a568d1 100644 --- a/telethon/_crypto/cdndecrypter.py +++ b/telethon/_crypto/cdndecrypter.py @@ -74,7 +74,7 @@ class CdnDecrypter: def get_file(self): """ - Calls GetCdnFileRequest and decrypts its bytes. + Calls GetCdnFile and decrypts its bytes. Also ensures that the file hasn't been tampered. :return: the CdnFile result. diff --git a/telethon/_network/mtprotostate.py b/telethon/_network/mtprotostate.py index ec777d75..f96554ac 100644 --- a/telethon/_network/mtprotostate.py +++ b/telethon/_network/mtprotostate.py @@ -102,7 +102,7 @@ class MTProtoState: # The `RequestState` stores `bytes(request)`, not the request itself. # `invokeAfterMsg` wants a `TLRequest` though, hence the wrapping. body = GzipPacked.gzip_if_smaller(content_related, - bytes(_tl.fn.InvokeAfterMsgRequest(after_id, _OpaqueRequest(data)))) + bytes(_tl.fn.InvokeAfterMsg(after_id, _OpaqueRequest(data)))) buffer.write(struct.pack(' types.InputMediaInvoice: - price = types.LabeledPrice(label=price_label, amount=price_amount) # label - just a text, amount=10000 means 100.00 - invoice = types.Invoice( + description: str, payload: str, start_param: str) -> _tl.InputMediaInvoice: + price = _tl.LabeledPrice(label=price_label, amount=price_amount) # label - just a text, amount=10000 means 100.00 + invoice = _tl.Invoice( currency=currency, # currency like USD prices=[price], # there could be a couple of prices. test=True, # if you're working with test token, else set test=False. @@ -114,14 +114,14 @@ def generate_invoice(price_label: str, price_amount: int, currency: str, title: phone_to_provider=False, email_to_provider=False ) - return types.InputMediaInvoice( + return _tl.InputMediaInvoice( title=title, description=description, invoice=invoice, payload=payload.encode('UTF-8'), # payload, which will be sent to next 2 handlers provider=provider_token, - provider_data=types.DataJSON('{}'), + provider_data=_tl.DataJSON('{}'), # data about the invoice, which will be shared with the payment provider. A detailed description of # required fields should be provided by the payment provider.