Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit ce2b782

Browse files
Update Pyrogram to v2.0.13
1 parent bb13e63 commit ce2b782

File tree

390 files changed

+8038
-5362
lines changed

Some content is hidden

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

390 files changed

+8038
-5362
lines changed

.github/workflows/python.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ jobs:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
os: [ubuntu-latest, macos-latest, windows-latest]
12-
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
11+
os: [ubuntu-latest, macos-latest]
12+
python-version: ["3.7", "3.8", "3.9", "3.10"]
1313

1414
steps:
1515
- uses: actions/checkout@v2
@@ -26,8 +26,9 @@ jobs:
2626
2727
- name: Generate API
2828
run: |
29-
python setup.py generate --api
29+
make venv
30+
make api
3031
3132
- name: Run tests
3233
run: |
33-
tox
34+
tox

Makefile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
VENV := venv
2+
PYTHON := $(VENV)/bin/python
3+
4+
RM := rm -rf
5+
6+
.PHONY: venv build docs
7+
8+
venv:
9+
$(RM) $(VENV)
10+
python3 -m venv $(VENV)
11+
$(PYTHON) -m pip install -U pip wheel setuptools
12+
$(PYTHON) -m pip install -U -r requirements.txt -r dev-requirements.txt -r docs/requirements.txt
13+
@echo "Created venv with $$($(PYTHON) --version)"
14+
15+
clean-build:
16+
$(RM) *.egg-info build dist
17+
18+
clean-docs:
19+
$(RM) docs/build
20+
$(RM) docs/source/api/bound-methods docs/source/api/methods docs/source/api/types docs/source/telegram
21+
22+
clean-api:
23+
$(RM) pyrogram/errors/exceptions pyrogram/raw/all.py pyrogram/raw/base pyrogram/raw/functions pyrogram/raw/types
24+
25+
clean:
26+
make clean-build
27+
make clean-docs
28+
make clean-api
29+
30+
api:
31+
cd compiler/api && ../../$(PYTHON) compiler.py
32+
cd compiler/errors && ../../$(PYTHON) compiler.py
33+
34+
docs-live:
35+
make clean-docs
36+
cd compiler/docs && ../../$(PYTHON) compiler.py
37+
$(RM) docs/source/telegram
38+
$(VENV)/bin/sphinx-autobuild \
39+
--host $(shell ifconfig | grep "inet " | grep -v 127.0.0.1 | cut -d\ -f2) \
40+
--watch pyrogram --watch docs/resources \
41+
-b html "docs/source" "docs/build/html" -j auto
42+
43+
docs:
44+
make clean-docs
45+
cd compiler/docs && ../../$(PYTHON) compiler.py
46+
$(VENV)/bin/sphinx-build \
47+
-b html "docs/source" "docs/build/html" -j auto
48+
49+
build:
50+
make clean-build
51+
make clean-api
52+
$(PYTHON) setup.py sdist
53+
$(PYTHON) setup.py bdist_wheel

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ If you'd like to support Pyrogram, you can consider:
5353
- **Ready**: Install Pyrogram with pip and start building your applications right away.
5454
- **Easy**: Makes the Telegram API simple and intuitive, while still allowing advanced usages.
5555
- **Elegant**: Low-level details are abstracted and re-presented in a more convenient way.
56-
- **Fast**: Boosted up by [TgCrypto](https://github.com/pyrogram/tgcrypto), a high-performance crypto library written in pure C.
56+
- **Fast**: Boosted up by [TgCrypto](https://github.com/pyrogram/tgcrypto), a high-performance cryptography library written in C.
5757
- **Type-hinted**: Types and methods are all type-hinted, enabling excellent editor support.
5858
- **Async**: Fully asynchronous (also usable synchronously if wanted, for convenience).
5959
- **Powerful**: Full access to Telegram's API to execute any official client action and more.

compiler/api/compiler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,14 @@ def start(format: bool = False):
361361

362362
for i, arg in enumerate(sorted_args):
363363
arg_name, arg_type = arg
364+
is_optional = FLAGS_RE.match(arg_type)
365+
flag_number = is_optional.group(1) if is_optional else -1
364366
arg_type = arg_type.split("?")[-1]
365367

366368
docstring_args.append(
367369
"{}{}: {}".format(
368370
arg_name,
369-
" (optional)",
371+
" (optional)".format(flag_number) if is_optional else "",
370372
get_docstring_arg_type(arg_type, is_pyrogram_type=c.namespace == "pyrogram")
371373
)
372374
)

compiler/api/source/main_api.tl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,4 +1801,4 @@ stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel
18011801
stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
18021802
stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats;
18031803

1804-
// LAYER 140
1804+
// LAYER 140

compiler/api/template/combinator.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class {name}(TLObject): # type: ignore
2727
{read_types}
2828
return {name}({return_arguments})
2929

30-
def write(self) -> bytes:
30+
def write(self, *args) -> bytes:
3131
b = BytesIO()
3232
b.write(Int(self.ID, False))
3333

compiler/docs/compiler.py

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,9 @@ def get_title_list(s: str) -> list:
171171
delete_messages
172172
get_messages
173173
get_media_group
174-
get_history
175-
get_history_count
176-
read_history
177-
iter_history
174+
get_chat_history
175+
get_chat_history_count
176+
read_chat_history
178177
send_poll
179178
vote_poll
180179
stop_poll
@@ -185,7 +184,10 @@ def get_title_list(s: str) -> list:
185184
search_global
186185
search_global_count
187186
download_media
187+
stream_media
188188
get_discussion_message
189+
get_discussion_replies
190+
get_discussion_replies_count
189191
""",
190192
chats="""
191193
Chats
@@ -208,11 +210,9 @@ def get_title_list(s: str) -> list:
208210
get_chat_member
209211
get_chat_members
210212
get_chat_members_count
211-
iter_chat_members
212213
get_dialogs
213-
iter_dialogs
214214
get_dialogs_count
215-
update_chat_username
215+
set_chat_username
216216
get_nearby_chats
217217
archive_chats
218218
unarchive_chats
@@ -235,12 +235,11 @@ def get_title_list(s: str) -> list:
235235
Users
236236
get_me
237237
get_users
238-
get_profile_photos
239-
get_profile_photos_count
240-
iter_profile_photos
238+
get_chat_photos
239+
get_chat_photos_count
241240
set_profile_photo
242241
delete_profile_photos
243-
update_username
242+
set_username
244243
update_profile
245244
block_user
246245
unblock_user
@@ -254,14 +253,17 @@ def get_title_list(s: str) -> list:
254253
edit_chat_invite_link
255254
revoke_chat_invite_link
256255
delete_chat_invite_link
257-
get_chat_invite_link_members
258-
get_chat_invite_link_members_count
256+
get_chat_invite_link_joiners
257+
get_chat_invite_link_joiners_count
259258
get_chat_admin_invite_links
260259
get_chat_admin_invite_links_count
261260
get_chat_admins_with_invite_links
261+
get_chat_join_requests
262262
delete_chat_admin_invite_links
263263
approve_chat_join_request
264+
approve_all_chat_join_requests
264265
decline_chat_join_request
266+
decline_all_chat_join_requests
265267
""",
266268
contacts="""
267269
Contacts
@@ -290,6 +292,11 @@ def get_title_list(s: str) -> list:
290292
set_bot_commands
291293
get_bot_commands
292294
delete_bot_commands
295+
set_bot_default_privileges
296+
get_bot_default_privileges
297+
set_chat_menu_button
298+
get_chat_menu_button
299+
answer_web_app_query
293300
""",
294301
authorization="""
295302
Authorization
@@ -311,7 +318,7 @@ def get_title_list(s: str) -> list:
311318
""",
312319
advanced="""
313320
Advanced
314-
send
321+
invoke
315322
resolve_peer
316323
save_file
317324
"""
@@ -339,7 +346,7 @@ def get_title_list(s: str) -> list:
339346
f2.write(title + "\n" + "=" * len(title) + "\n\n")
340347
f2.write(".. automethod:: pyrogram.Client.{}()".format(method))
341348

342-
functions = ["idle"]
349+
functions = ["idle", "compose"]
343350

344351
for func in functions:
345352
with open(root + "/{}.rst".format(func), "w") as f2:
@@ -361,12 +368,14 @@ def get_title_list(s: str) -> list:
361368
ChatPhoto
362369
ChatMember
363370
ChatPermissions
371+
ChatPrivileges
364372
ChatInviteLink
365373
ChatAdminWithInviteLinks
366374
ChatEvent
367375
ChatEventFilter
368376
ChatMemberUpdated
369377
ChatJoinRequest
378+
ChatJoiner
370379
Dialog
371380
Restriction
372381
""",
@@ -392,10 +401,11 @@ def get_title_list(s: str) -> list:
392401
PollOption
393402
Dice
394403
Reaction
395-
VoiceChatScheduled
396-
VoiceChatStarted
397-
VoiceChatEnded
398-
VoiceChatMembersInvited
404+
VideoChatScheduled
405+
VideoChatStarted
406+
VideoChatEnded
407+
VideoChatMembersInvited
408+
WebAppData
399409
""",
400410
bot_keyboards="""
401411
Bot keyboards
@@ -409,6 +419,12 @@ def get_title_list(s: str) -> list:
409419
CallbackQuery
410420
GameHighScore
411421
CallbackGame
422+
WebAppInfo
423+
MenuButton
424+
MenuButtonCommands
425+
MenuButtonWebApp
426+
MenuButtonDefault
427+
SentWebAppMessage
412428
""",
413429
bot_commands="""
414430
Bot commands
@@ -436,11 +452,23 @@ def get_title_list(s: str) -> list:
436452
Inline Mode
437453
InlineQuery
438454
InlineQueryResult
455+
InlineQueryResultCachedAudio
456+
InlineQueryResultCachedDocument
457+
InlineQueryResultCachedAnimation
458+
InlineQueryResultCachedPhoto
459+
InlineQueryResultCachedSticker
460+
InlineQueryResultCachedVideo
461+
InlineQueryResultCachedVoice
439462
InlineQueryResultArticle
440-
InlineQueryResultPhoto
441-
InlineQueryResultAnimation
442463
InlineQueryResultAudio
464+
InlineQueryResultContact
465+
InlineQueryResultDocument
466+
InlineQueryResultAnimation
467+
InlineQueryResultLocation
468+
InlineQueryResultPhoto
469+
InlineQueryResultVenue
443470
InlineQueryResultVideo
471+
InlineQueryResultVoice
444472
ChosenInlineResult
445473
""",
446474
input_message_content="""
@@ -533,12 +561,12 @@ def get_title_list(s: str) -> list:
533561
Chat.promote_member
534562
Chat.get_member
535563
Chat.get_members
536-
Chat.iter_members
537564
Chat.add_members
538565
Chat.join
539566
Chat.leave
540567
Chat.mark_unread
541568
Chat.set_protected_content
569+
Chat.unpin_all_messages
542570
""",
543571
user="""
544572
User

compiler/docs/template/methods.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Available Methods
22
=================
33

4-
This page is about Pyrogram methods. All the methods listed here are bound to a :class:`~pyrogram.Client` instance.
5-
Some other utility functions can instead be found in the main package directly.
4+
This page is about Pyrogram methods. All the methods listed here are bound to a :class:`~pyrogram.Client` instance,
5+
except for :meth:`~pyrogram.idle()` and :meth:`~pyrogram.compose()`, which are special functions that can be found in
6+
the main package directly.
67

78
.. code-block:: python
89
@@ -40,11 +41,13 @@ Utilities
4041
:nosignatures:
4142

4243
idle
44+
compose
4345

4446
.. toctree::
4547
:hidden:
4648

4749
idle
50+
compose
4851

4952
.. currentmodule:: pyrogram.Client
5053

compiler/errors/compiler.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ def start():
133133
with open("{}/all.py".format(DEST), "w", encoding="utf-8") as f:
134134
f.write(re.sub("{count}", str(count), content))
135135

136-
print("Compiling Errors: [100%]")
137-
138136

139137
if "__main__" == __name__:
140138
HOME = "."
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
id message
2-
FILE_MIGRATE_X The file to be accessed is currently stored in DC{x}
3-
NETWORK_MIGRATE_X The source IP address is associated with DC{x} (for registration)
4-
PHONE_MIGRATE_X The phone number a user is trying to use for authorization is associated with DC{x}
5-
STATS_MIGRATE_X The statistics of the group/channel are stored in DC{x}
6-
USER_MIGRATE_X The user whose identity is being used to execute queries is associated with DC{x} (for registration)
2+
FILE_MIGRATE_X The file to be accessed is currently stored in DC{value}
3+
NETWORK_MIGRATE_X The source IP address is associated with DC{value} (for registration)
4+
PHONE_MIGRATE_X The phone number a user is trying to use for authorization is associated with DC{value}
5+
STATS_MIGRATE_X The statistics of the group/channel are stored in DC{value}
6+
USER_MIGRATE_X The user whose identity is being used to execute queries is associated with DC{value} (for registration)

0 commit comments

Comments
 (0)