Skip to content

Commit d4dbff3

Browse files
committed
Merge develop -> asyncio
2 parents 3943925 + 4d97aae commit d4dbff3

131 files changed

Lines changed: 1828 additions & 1550 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.

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: delivrance
2+
custom: https://docs.pyrogram.org/support-pyrogram

compiler/api/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ def start():
333333
docstring_args = "No parameters required."
334334

335335
docstring_args = "Attributes:\n ID: ``{}``\n\n ".format(c.id) + docstring_args
336+
docstring_args = "Attributes:\n LAYER: ``{}``\n\n ".format(layer) + docstring_args
336337

337338
if c.section == "functions":
338339
docstring_args += "\n\n Returns:\n " + get_docstring_arg_type(c.return_type)

compiler/api/source/main_api.tl

Lines changed: 84 additions & 43 deletions
Large diffs are not rendered by default.

compiler/docs/compiler.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import ast
2020
import os
21+
import re
2122
import shutil
2223

2324
HOME = "compiler/docs"
@@ -29,8 +30,10 @@
2930
FUNCTIONS_BASE = "functions"
3031
TYPES_BASE = "types"
3132

32-
shutil.rmtree(TYPES_BASE, ignore_errors=True)
33-
shutil.rmtree(FUNCTIONS_BASE, ignore_errors=True)
33+
34+
def snek(s: str):
35+
s = re.sub(r"(.)([A-Z][a-z]+)", r"\1_\2", s)
36+
return re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", s).lower()
3437

3538

3639
def generate(source_path, base):
@@ -50,9 +53,11 @@ def build(path, level=0):
5053
for node in ast.walk(p):
5154
if isinstance(node, ast.ClassDef):
5255
name = node.name
56+
break
57+
else:
58+
continue
5359

54-
# name = "".join([str(j.title()) for j in os.path.splitext(i)[0].split("_")])
55-
full_path = os.path.basename(path) + "/" + name + ".rst"
60+
full_path = os.path.basename(path) + "/" + snek(name).replace("_", "-") + ".rst"
5661

5762
if level:
5863
full_path = base + "/" + full_path
@@ -65,7 +70,7 @@ def build(path, level=0):
6570
title=name,
6671
title_markup="=" * len(name),
6772
full_class_path="pyrogram.api.{}".format(
68-
os.path.splitext(full_path)[0].replace("/", ".")
73+
".".join(full_path.split("/")[:-1]) + "." + name
6974
)
7075
)
7176
)
@@ -82,7 +87,7 @@ def build(path, level=0):
8287
entities = []
8388

8489
for i in v:
85-
entities.append(i)
90+
entities.append(snek(i).replace("_", "-"))
8691

8792
if k != base:
8893
inner_path = base + "/" + k + "/index" + ".rst"
@@ -98,6 +103,7 @@ def build(path, level=0):
98103
with open(DESTINATION + "/" + inner_path, "w", encoding="utf-8") as f:
99104
if k == base:
100105
f.write(":tocdepth: 1\n\n")
106+
k = "Raw " + k
101107

102108
f.write(
103109
toctree.format(
@@ -115,6 +121,8 @@ def start():
115121
global page_template
116122
global toctree
117123

124+
shutil.rmtree(DESTINATION, ignore_errors=True)
125+
118126
with open(HOME + "/template/page.txt", encoding="utf-8") as f:
119127
page_template = f.read()
120128

compiler/error/source/400_BAD_REQUEST.tsv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,5 @@ RESULTS_TOO_MUCH The result contains too many items
9898
RESULT_ID_DUPLICATE The result contains items with duplicated identifiers
9999
ACCESS_TOKEN_INVALID The bot access token is invalid
100100
INVITE_HASH_EXPIRED The chat invite link is no longer valid
101-
USER_BANNED_IN_CHANNEL You are limited, check @SpamBot for details
101+
USER_BANNED_IN_CHANNEL You are limited, check @SpamBot for details
102+
MESSAGE_EDIT_TIME_EXPIRED You can no longer edit this message

compiler/error/source/401_UNAUTHORIZED.tsv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ id message
22
AUTH_KEY_UNREGISTERED The key is not registered in the system
33
AUTH_KEY_INVALID The key is invalid
44
USER_DEACTIVATED The user has been deleted/deactivated
5+
USER_DEACTIVATED_BAN The user has been deleted/deactivated
56
SESSION_REVOKED The authorization has been invalidated, because of the user terminating all sessions
67
SESSION_EXPIRED The authorization has expired
78
ACTIVE_USER_REQUIRED The method is only available to already activated users

docs/sitemap.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
dirs = {
2525
".": ("weekly", 1.0),
26-
"intro": ("weekly", 0.8),
27-
"start": ("weekly", 0.8),
28-
"api": ("weekly", 0.6),
29-
"topics": ("weekly", 0.6),
30-
"telegram": ("weekly", 0.4)
26+
"intro": ("weekly", 0.9),
27+
"start": ("weekly", 0.9),
28+
"api": ("weekly", 0.8),
29+
"topics": ("weekly", 0.8),
30+
"telegram": ("weekly", 0.6)
3131
}
3232

3333

docs/source/api/bound-methods.rst

Lines changed: 58 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,65 @@ some of the required arguments.
2222
2323
.. currentmodule:: pyrogram
2424

25-
- Message_
26-
- CallbackQuery_
27-
- InlineQuery_
28-
29-
.. _Message:
25+
Index
26+
-----
3027

3128
Message
32-
-------
29+
^^^^^^^
30+
31+
.. hlist::
32+
:columns: 3
33+
34+
- :meth:`~Message.click`
35+
- :meth:`~Message.delete`
36+
- :meth:`~Message.download`
37+
- :meth:`~Message.edit`
38+
- :meth:`~Message.edit_caption`
39+
- :meth:`~Message.edit_media`
40+
- :meth:`~Message.edit_reply_markup`
41+
- :meth:`~Message.forward`
42+
- :meth:`~Message.pin`
43+
- :meth:`~Message.reply`
44+
- :meth:`~Message.reply_animation`
45+
- :meth:`~Message.reply_audio`
46+
- :meth:`~Message.reply_cached_media`
47+
- :meth:`~Message.reply_chat_action`
48+
- :meth:`~Message.reply_contact`
49+
- :meth:`~Message.reply_document`
50+
- :meth:`~Message.reply_game`
51+
- :meth:`~Message.reply_inline_bot_result`
52+
- :meth:`~Message.reply_location`
53+
- :meth:`~Message.reply_media_group`
54+
- :meth:`~Message.reply_photo`
55+
- :meth:`~Message.reply_poll`
56+
- :meth:`~Message.reply_sticker`
57+
- :meth:`~Message.reply_venue`
58+
- :meth:`~Message.reply_video`
59+
- :meth:`~Message.reply_video_note`
60+
- :meth:`~Message.reply_voice`
61+
62+
CallbackQuery
63+
^^^^^^^^^^^^^
64+
65+
.. hlist::
66+
:columns: 2
67+
68+
- :meth:`~CallbackQuery.answer`
69+
70+
InlineQuery
71+
^^^^^^^^^^^
72+
73+
.. hlist::
74+
:columns: 2
3375

34-
- :meth:`Message.click()`
35-
- :meth:`Message.delete()`
36-
- :meth:`Message.download()`
37-
- :meth:`Message.edit()`
38-
- :meth:`Message.edit_caption()`
39-
- :meth:`Message.edit_media()`
40-
- :meth:`Message.edit_reply_markup()`
41-
- :meth:`Message.forward()`
42-
- :meth:`Message.pin()`
43-
- :meth:`Message.reply()`
44-
- :meth:`Message.reply_animation()`
45-
- :meth:`Message.reply_audio()`
46-
- :meth:`Message.reply_cached_media()`
47-
- :meth:`Message.reply_chat_action()`
48-
- :meth:`Message.reply_contact()`
49-
- :meth:`Message.reply_document()`
50-
- :meth:`Message.reply_game()`
51-
- :meth:`Message.reply_inline_bot_result()`
52-
- :meth:`Message.reply_location()`
53-
- :meth:`Message.reply_media_group()`
54-
- :meth:`Message.reply_photo()`
55-
- :meth:`Message.reply_poll()`
56-
- :meth:`Message.reply_sticker()`
57-
- :meth:`Message.reply_venue()`
58-
- :meth:`Message.reply_video()`
59-
- :meth:`Message.reply_video_note()`
60-
- :meth:`Message.reply_voice()`
76+
- :meth:`~InlineQuery.answer`
6177

78+
-----
79+
80+
Details
81+
-------
82+
83+
.. Message
6284
.. automethod:: Message.click()
6385
.. automethod:: Message.delete()
6486
.. automethod:: Message.download()
@@ -87,16 +109,8 @@ Message
87109
.. automethod:: Message.reply_video_note()
88110
.. automethod:: Message.reply_voice()
89111

90-
.. _CallbackQuery:
91-
92-
CallbackQuery
93-
-------------
94-
112+
.. CallbackQuery
95113
.. automethod:: CallbackQuery.answer()
96114

97-
.. _InlineQuery:
98-
99-
InlineQuery
100-
-----------
101-
102-
.. automethod:: InlineQuery.answer()
115+
.. InlineQuery
116+
.. automethod:: InlineQuery.answer()

docs/source/api/decorators.rst

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Decorators
22
==========
33

4-
While still being methods bound to the :obj:`Client <pyrogram.Client>` class, decorators are of a special kind and thus deserve a
5-
dedicated page.
4+
While still being methods bound to the :class:`~pyrogram.Client` class, decorators are of a special kind and thus
5+
deserve a dedicated page.
66

77
Decorators are able to register callback functions for handling updates in a much easier and cleaner way compared to
8-
`Handlers <Handlers.html>`_; they do so by instantiating the correct handler and calling
9-
:meth:`add_handler() <pyrogram.Client.add_handler>`, automatically. All you need to do is adding the decorators on top
10-
of your functions.
8+
:doc:`Handlers <handlers>`; they do so by instantiating the correct handler and calling
9+
:meth:`~pyrogram.Client.add_handler`, automatically. All you need to do is adding the decorators on top of your
10+
functions.
1111

1212
.. code-block:: python
1313
:emphasize-lines: 6
@@ -24,25 +24,34 @@ of your functions.
2424
2525
app.run()
2626
27-
.. currentmodule:: pyrogram.Client
28-
29-
.. autosummary::
30-
:nosignatures:
31-
32-
on_message
33-
on_callback_query
34-
on_inline_query
35-
on_deleted_messages
36-
on_user_status
37-
on_poll
38-
on_disconnect
39-
on_raw_update
40-
41-
.. automethod:: pyrogram.Client.on_message()
42-
.. automethod:: pyrogram.Client.on_callback_query()
43-
.. automethod:: pyrogram.Client.on_inline_query()
44-
.. automethod:: pyrogram.Client.on_deleted_messages()
45-
.. automethod:: pyrogram.Client.on_user_status()
46-
.. automethod:: pyrogram.Client.on_poll()
47-
.. automethod:: pyrogram.Client.on_disconnect()
48-
.. automethod:: pyrogram.Client.on_raw_update()
27+
.. currentmodule:: pyrogram
28+
29+
Index
30+
-----
31+
32+
.. hlist::
33+
:columns: 3
34+
35+
- :meth:`~Client.on_message`
36+
- :meth:`~Client.on_callback_query`
37+
- :meth:`~Client.on_inline_query`
38+
- :meth:`~Client.on_deleted_messages`
39+
- :meth:`~Client.on_user_status`
40+
- :meth:`~Client.on_poll`
41+
- :meth:`~Client.on_disconnect`
42+
- :meth:`~Client.on_raw_update`
43+
44+
-----
45+
46+
Details
47+
-------
48+
49+
.. Decorators
50+
.. autodecorator:: pyrogram.Client.on_message()
51+
.. autodecorator:: pyrogram.Client.on_callback_query()
52+
.. autodecorator:: pyrogram.Client.on_inline_query()
53+
.. autodecorator:: pyrogram.Client.on_deleted_messages()
54+
.. autodecorator:: pyrogram.Client.on_user_status()
55+
.. autodecorator:: pyrogram.Client.on_poll()
56+
.. autodecorator:: pyrogram.Client.on_disconnect()
57+
.. autodecorator:: pyrogram.Client.on_raw_update()

docs/source/api/handlers.rst

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Update Handlers
33

44
Handlers are used to instruct Pyrogram about which kind of updates you'd like to handle with your callback functions.
55

6-
For a much more convenient way of registering callback functions have a look at `Decorators <Decorators.html>`_ instead.
7-
In case you decided to manually create a handler, use :meth:`add_handler() <pyrogram.Client.add_handler>` to register
6+
For a much more convenient way of registering callback functions have a look at :doc:`Decorators <decorators>` instead.
7+
In case you decided to manually create a handler, use :class:`~pyrogram.Client.add_handler` to register
88
it.
99

1010
.. code-block:: python
@@ -25,18 +25,27 @@ it.
2525
2626
.. currentmodule:: pyrogram
2727

28-
.. autosummary::
29-
:nosignatures:
28+
Index
29+
-----
3030

31-
MessageHandler
32-
DeletedMessagesHandler
33-
CallbackQueryHandler
34-
InlineQueryHandler
35-
UserStatusHandler
36-
PollHandler
37-
DisconnectHandler
38-
RawUpdateHandler
31+
.. hlist::
32+
:columns: 3
3933

34+
- :class:`MessageHandler`
35+
- :class:`DeletedMessagesHandler`
36+
- :class:`CallbackQueryHandler`
37+
- :class:`InlineQueryHandler`
38+
- :class:`UserStatusHandler`
39+
- :class:`PollHandler`
40+
- :class:`DisconnectHandler`
41+
- :class:`RawUpdateHandler`
42+
43+
-----
44+
45+
Details
46+
-------
47+
48+
.. Handlers
4049
.. autoclass:: MessageHandler()
4150
.. autoclass:: DeletedMessagesHandler()
4251
.. autoclass:: CallbackQueryHandler()

0 commit comments

Comments
 (0)