Skip to content

Commit 78efb04

Browse files
committed
Rename Client.send to Client.invoke
1 parent 4f6ce8b commit 78efb04

144 files changed

Lines changed: 234 additions & 236 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pyrogram/client.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ async def handle_updates(self, updates):
567567

568568
if not isinstance(message, raw.types.MessageEmpty):
569569
try:
570-
diff = await self.send(
570+
diff = await self.invoke(
571571
raw.functions.updates.GetChannelDifference(
572572
channel=await self.resolve_peer(utils.get_channel_id(channel_id)),
573573
filter=raw.types.ChannelMessagesFilter(
@@ -589,7 +589,7 @@ async def handle_updates(self, updates):
589589

590590
self.dispatcher.updates_queue.put_nowait((update, users, chats))
591591
elif isinstance(updates, (raw.types.UpdateShortMessage, raw.types.UpdateShortChatMessage)):
592-
diff = await self.send(
592+
diff = await self.invoke(
593593
raw.functions.updates.GetDifference(
594594
pts=updates.pts - updates.pts_count,
595595
date=updates.date,
@@ -847,14 +847,14 @@ async def get_file(
847847
await session.start()
848848

849849
for _ in range(3):
850-
exported_auth = await self.send(
850+
exported_auth = await self.invoke(
851851
raw.functions.auth.ExportAuthorization(
852852
dc_id=dc_id
853853
)
854854
)
855855

856856
try:
857-
await session.send(
857+
await session.invoke(
858858
raw.functions.auth.ImportAuthorization(
859859
id=exported_auth.id,
860860
bytes=exported_auth.bytes
@@ -920,7 +920,7 @@ async def get_file(
920920
file_name = ""
921921

922922
try:
923-
r = await session.send(
923+
r = await session.invoke(
924924
raw.functions.upload.GetFile(
925925
location=location,
926926
offset=offset,
@@ -958,7 +958,7 @@ async def get_file(
958958
if len(chunk) < limit:
959959
break
960960

961-
r = await session.send(
961+
r = await session.invoke(
962962
raw.functions.upload.GetFile(
963963
location=location,
964964
offset=offset,
@@ -986,7 +986,7 @@ async def get_file(
986986
file_name = f.name
987987

988988
while True:
989-
r2 = await cdn_session.send(
989+
r2 = await cdn_session.invoke(
990990
raw.functions.upload.GetCdnFile(
991991
file_token=r.file_token,
992992
offset=offset,
@@ -996,7 +996,7 @@ async def get_file(
996996

997997
if isinstance(r2, raw.types.upload.CdnFileReuploadNeeded):
998998
try:
999-
await session.send(
999+
await session.invoke(
10001000
raw.functions.upload.ReuploadCdnFile(
10011001
file_token=r.file_token,
10021002
request_token=r2.request_token
@@ -1019,7 +1019,7 @@ async def get_file(
10191019
)
10201020
)
10211021

1022-
hashes = await session.send(
1022+
hashes = await session.invoke(
10231023
raw.functions.upload.GetCdnFileHashes(
10241024
file_token=r.file_token,
10251025
offset=offset

pyrogram/methods/advanced/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
from .invoke import Invoke
1920
from .resolve_peer import ResolvePeer
2021
from .save_file import SaveFile
21-
from .send import Send
2222

2323

2424
class Advanced(
25+
Invoke,
2526
ResolvePeer,
26-
SaveFile,
27-
Send
27+
SaveFile
2828
):
2929
pass
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
log = logging.getLogger(__name__)
2727

2828

29-
class Send:
30-
async def send(
29+
class Invoke:
30+
async def invoke(
3131
self: "pyrogram.Client",
32-
data: TLObject,
32+
query: TLObject,
3333
retries: int = Session.MAX_RETRIES,
3434
timeout: float = Session.WAIT_TIMEOUT,
3535
sleep_threshold: float = None
3636
):
37-
"""Send raw Telegram queries.
37+
"""Invoke raw Telegram functions.
3838
3939
This method makes it possible to manually call every single Telegram API method in a low-level manner.
4040
Available functions are listed in the :obj:`functions <pyrogram.api.functions>` package and may accept compound
@@ -47,7 +47,7 @@ async def send(
4747
available yet in the Client class as an easy-to-use method).
4848
4949
Parameters:
50-
data (``RawFunction``):
50+
query (``RawFunction``):
5151
The API Schema function filled with proper arguments.
5252
5353
retries (``int``):
@@ -69,13 +69,13 @@ async def send(
6969
raise ConnectionError("Client has not been started yet")
7070

7171
if self.no_updates:
72-
data = raw.functions.InvokeWithoutUpdates(query=data)
72+
query = raw.functions.InvokeWithoutUpdates(query=query)
7373

7474
if self.takeout_id:
75-
data = raw.functions.InvokeWithTakeout(takeout_id=self.takeout_id, query=data)
75+
query = raw.functions.InvokeWithTakeout(takeout_id=self.takeout_id, query=query)
7676

77-
r = await self.session.send(
78-
data, retries, timeout,
77+
r = await self.session.invoke(
78+
query, retries, timeout,
7979
(sleep_threshold
8080
if sleep_threshold is not None
8181
else self.sleep_threshold)

pyrogram/methods/advanced/resolve_peer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def resolve_peer(
7171
try:
7272
return await self.storage.get_peer_by_username(peer_id)
7373
except KeyError:
74-
await self.send(
74+
await self.invoke(
7575
raw.functions.contacts.ResolveUsername(
7676
username=peer_id
7777
)
@@ -88,7 +88,7 @@ async def resolve_peer(
8888

8989
if peer_type == "user":
9090
await self.fetch_peers(
91-
await self.send(
91+
await self.invoke(
9292
raw.functions.users.GetUsers(
9393
id=[
9494
raw.types.InputUser(
@@ -100,13 +100,13 @@ async def resolve_peer(
100100
)
101101
)
102102
elif peer_type == "chat":
103-
await self.send(
103+
await self.invoke(
104104
raw.functions.messages.GetChats(
105105
id=[-peer_id]
106106
)
107107
)
108108
else:
109-
await self.send(
109+
await self.invoke(
110110
raw.functions.channels.GetChannels(
111111
id=[
112112
raw.types.InputChannel(

pyrogram/methods/advanced/save_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ async def worker(session):
103103
return
104104

105105
try:
106-
await session.send(data)
106+
await session.invoke(data)
107107
except Exception as e:
108108
log.error(e)
109109

pyrogram/methods/auth/accept_terms_of_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def accept_terms_of_service(
3131
terms_of_service_id (``str``):
3232
The terms of service identifier.
3333
"""
34-
r = await self.send(
34+
r = await self.invoke(
3535
raw.functions.help.AcceptTermsOfService(
3636
id=raw.types.DataJSON(
3737
data=terms_of_service_id

pyrogram/methods/auth/check_password.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ async def check_password(
4343
Raises:
4444
BadRequest: In case the password is invalid.
4545
"""
46-
r = await self.send(
46+
r = await self.invoke(
4747
raw.functions.auth.CheckPassword(
4848
password=compute_password_check(
49-
await self.send(raw.functions.account.GetPassword()),
49+
await self.invoke(raw.functions.account.GetPassword()),
5050
password
5151
)
5252
)

pyrogram/methods/auth/get_password_hint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ async def get_password_hint(
3333
Returns:
3434
``str``: On success, the password hint as string is returned.
3535
"""
36-
return (await self.send(raw.functions.account.GetPassword())).hint
36+
return (await self.invoke(raw.functions.account.GetPassword())).hint

pyrogram/methods/auth/log_out.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def log_out(
4242
# Log out.
4343
app.log_out()
4444
"""
45-
await self.send(raw.functions.auth.LogOut())
45+
await self.invoke(raw.functions.auth.LogOut())
4646
await self.stop()
4747
await self.storage.delete()
4848

pyrogram/methods/auth/recover_password.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async def recover_password(
4343
Raises:
4444
BadRequest: In case the recovery code is invalid.
4545
"""
46-
r = await self.send(
46+
r = await self.invoke(
4747
raw.functions.auth.RecoverPassword(
4848
code=recovery_code
4949
)

0 commit comments

Comments
 (0)