Skip to content

Commit 31960d0

Browse files
authored
Merge branch 'develop' into other_start
2 parents 52902d4 + 3dc2a81 commit 31960d0

File tree

181 files changed

+2573
-1179
lines changed

Some content is hidden

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

181 files changed

+2573
-1179
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ pyrogram/api/all.py
1111
# PyCharm stuff
1212
.idea/
1313

14+
# VS Code
15+
.vscode/
16+
1417
# Byte-compiled / optimized / DLL files
1518
__pycache__/
1619
*.py[cod]
@@ -78,6 +81,7 @@ instance/
7881

7982
# Sphinx documentation
8083
docs/_build/
84+
docs/source/_build
8185

8286
# PyBuilder
8387
target/

compiler/api/compiler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ def start():
478478

479479
f.write("\n 0xbc799737: \"pyrogram.api.core.BoolFalse\",")
480480
f.write("\n 0x997275b5: \"pyrogram.api.core.BoolTrue\",")
481-
f.write("\n 0x56730bcc: \"pyrogram.api.core.Null\",")
482481
f.write("\n 0x1cb5c415: \"pyrogram.api.core.Vector\",")
483482
f.write("\n 0x73f1f8dc: \"pyrogram.api.core.MsgContainer\",")
484483
f.write("\n 0xae500895: \"pyrogram.api.core.FutureSalts\",")

compiler/api/source/main_api.tl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,4 @@ langpack.getLanguage#6a596502 lang_pack:string lang_code:string = LangPackLangua
13641364
folders.editPeerFolders#6847d0ab folder_peers:Vector<InputFolderPeer> = Updates;
13651365
folders.deleteFolder#1c295881 folder_id:int = Updates;
13661366

1367-
// LAYER 103
1368-
1369-
// Ports
1370-
channels.exportInvite#c7560885 channel:InputChannel = ExportedChatInvite;
1367+
// LAYER 103

compiler/api/source/sys_msgs.tl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ ipPortSecret#37982646 ipv4:int port:int secret:bytes = IpPort;
5353
accessPointRule#4679b65f phone_prefix_rules:string dc_id:int ips:vector<IpPort> = AccessPointRule;
5454
help.configSimple#5a592a6c date:int expires:int rules:vector<AccessPointRule> = help.ConfigSimple;
5555

56+
// tlsClientHello blocks:vector<TlsBlock> = TlsClientHello;
57+
//
58+
// tlsBlockString data:string = TlsBlock;
59+
// tlsBlockRandom length:int = TlsBlock;
60+
// tlsBlockZero length:int = TlsBlock;
61+
// tlsBlockDomain = TlsBlock;
62+
// tlsBlockGrease seed:int = TlsBlock;
63+
// tlsBlockScope entries:Vector<TlsBlock> = TlsBlock;
64+
5665
---functions---
5766

5867
rpc_drop_answer#58e4a740 req_msg_id:long = RpcDropAnswer;

compiler/docs/compiler.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def get_title_list(s: str) -> list:
136136
remove_handler
137137
stop_transmission
138138
export_session_string
139+
set_parse_mode
139140
""",
140141
messages="""
141142
Messages
@@ -145,7 +146,6 @@ def get_title_list(s: str) -> list:
145146
send_audio
146147
send_document
147148
send_sticker
148-
send_animated_sticker
149149
send_video
150150
send_animation
151151
send_voice
@@ -189,6 +189,7 @@ def get_title_list(s: str) -> list:
189189
delete_chat_photo
190190
set_chat_title
191191
set_chat_description
192+
set_chat_permissions
192193
pin_chat_message
193194
unpin_chat_message
194195
get_chat
@@ -199,10 +200,15 @@ def get_title_list(s: str) -> list:
199200
get_dialogs
200201
iter_dialogs
201202
get_dialogs_count
202-
restrict_chat
203203
update_chat_username
204204
archive_chats
205205
unarchive_chats
206+
add_chat_members
207+
create_channel
208+
create_group
209+
create_supergroup
210+
delete_channel
211+
delete_supergroup
206212
""",
207213
users="""
208214
Users
@@ -334,6 +340,8 @@ def get_title_list(s: str) -> list:
334340
InlineQuery
335341
InlineQueryResult
336342
InlineQueryResultArticle
343+
InlineQueryResultPhoto
344+
InlineQueryResultAnimation
337345
""",
338346
input_message_content="""
339347
InputMessageContent
@@ -412,11 +420,15 @@ def get_title_list(s: str) -> list:
412420
Chat.unban_member
413421
Chat.restrict_member
414422
Chat.promote_member
423+
Chat.join
424+
Chat.leave
415425
""",
416426
user="""
417427
User
418428
User.archive
419429
User.unarchive
430+
User.block
431+
User.unblock
420432
""",
421433
callback_query="""
422434
Callback Query

compiler/error/source/400_BAD_REQUEST.tsv

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,13 @@ FILE_PART_TOO_BIG The size limit (512 KB) for the content of the file part has b
113113
FILE_PART_EMPTY The file part sent is empty
114114
FILE_PART_SIZE_INVALID 512 KB cannot be evenly divided by part_size
115115
FILE_PART_SIZE_CHANGED The part size is different from the size of one of the previous parts in the same file
116-
FILE_MIGRATE_X The file is in Data Center No. {x}
116+
FILE_MIGRATE_X The file is in Data Center No. {x}
117+
RESULT_TYPE_INVALID The result type is invalid
118+
PHOTO_THUMB_URL_EMPTY The photo thumb URL is empty
119+
PHOTO_THUMB_URL_INVALID The photo thumb URL is invalid
120+
PHOTO_CONTENT_URL_EMPTY The photo content URL is empty
121+
PHOTO_CONTENT_TYPE_INVALID The photo content type is invalid
122+
WEBDOCUMENT_INVALID The web document is invalid
123+
WEBDOCUMENT_URL_EMPTY The web document URL is empty
124+
WEBDOCUMENT_URL_INVALID The web document URL is invalid
125+
WEBDOCUMENT_MIME_INVALID The web document mime type is invalid

docs/source/faq.rst

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ I started a client and nothing happens!
144144
---------------------------------------
145145

146146
If you are connecting from Russia, China or Iran :doc:`you need a proxy <topics/proxy>`, because Telegram could be
147-
partially or totally blocked in those countries.
147+
partially or totally blocked in those countries. More information about this block can be found at
148+
`Wikipedia <https://en.wikipedia.org/wiki/Blocking_Telegram_in_Russia>`_.
148149

149150
Another possible cause might be network issues, either yours or Telegram's. To confirm this, add the following code on
150151
the top of your script and run it again. You should see some error mentioning a socket timeout or an unreachable network
@@ -161,9 +162,9 @@ fails or not.
161162
What are the IP addresses of Telegram Data Centers?
162163
---------------------------------------------------
163164

164-
The Telegram cloud is currently composed by a decentralized, multi-DC infrastructure (each of which can work
165-
independently) spread in 5 different locations. However, some of the less busy DCs have been lately dismissed and their
166-
IP addresses are now kept as aliases.
165+
The Telegram cloud is currently composed by a decentralized, multi-DC infrastructure (currently 5 DCs, each of which can
166+
work independently) spread in different locations worldwide. However, some of the less busy DCs have been lately
167+
dismissed and their IP addresses are now kept as aliases to the nearest one.
167168

168169
.. csv-table:: Production Environment
169170
:header: ID, Location, IPv4, IPv6
@@ -191,7 +192,6 @@ IP addresses are now kept as aliases.
191192

192193
Thanks to `@FrayxRulez <https://t.me/tgbetachat/104921>`_ for telling about alias DCs.
193194

194-
195195
I want to migrate my account from DCX to DCY.
196196
---------------------------------------------
197197

@@ -245,9 +245,13 @@ The error in question is ``[400 PEER_ID_INVALID]``, and could mean several thing
245245

246246
- The chat id you tried to use is simply wrong, double check it.
247247
- The chat id refers to a group or channel you are not a member of.
248-
- The chat id refers to a user you have't seen yet (from contacts, groups in common, forwarded messages or private
249-
chats).
250248
- The chat id argument you passed is in form of a string; you have to convert it into an integer with ``int(chat_id)``.
249+
- The chat id refers to a user your current session haven't met yet.
250+
251+
About the last point: in order for you to meet a user and thus communicate with them, you should ask yourself how to
252+
contact people using official apps. The answer is the same for Pyrogram too and involves normal usages such as searching
253+
for usernames, meet them in a common group, have their phone contacts saved, getting a message mentioning them (either a
254+
forward or a mention in the message text).
251255

252256
UnicodeEncodeError: '<encoding>' codec can't encode …
253257
-----------------------------------------------------
@@ -257,6 +261,14 @@ shows up when you try to print something and has very little to do with Pyrogram
257261
your own terminal. To fix it, either find a way to change the encoding settings of your terminal to UTF-8 or switch to a
258262
better terminal altogether.
259263

264+
Uploading with URLs gives error WEBPAGE_CURL_FAILED
265+
---------------------------------------------------
266+
267+
When uploading media files using an URL, the server automatically tries to download the media and uploads it to the
268+
Telegram cloud. This error usually happens in case the provided URL is not publicly accessible by Telegram itself or the
269+
media exceeds 20 MB in size. In such cases, your only option is to download the media yourself and upload from your
270+
local machine.
271+
260272
My verification code expires immediately!
261273
-----------------------------------------
262274

docs/source/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ Welcome to Pyrogram
4545
topics/tgcrypto
4646
topics/storage-engines
4747
topics/text-formatting
48-
topics/serialize
48+
topics/serializing
4949
topics/proxy
50+
topics/scheduling
5051
topics/bots-interaction
5152
topics/mtproto-vs-botapi
5253
topics/debugging

docs/source/topics/scheduling.rst

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
Scheduling Tasks
2+
================
3+
4+
Scheduling tasks means executing one or more functions periodically at pre-defined intervals or after a delay. This is
5+
useful, for example, to send recurring messages to specific chats or users.
6+
7+
Since there's no built-in task scheduler in Pyrogram, this page will only show examples on how to integrate Pyrogram
8+
with the main Python schedule libraries such as ``schedule`` and ``apscheduler``. For more detailed information, you can
9+
visit and learn from each library documentation.
10+
11+
Using ``schedule``
12+
------------------
13+
14+
- Install with ``pip3 install schedule``
15+
- Documentation: https://schedule.readthedocs.io
16+
17+
.. code-block:: python
18+
19+
import time
20+
21+
import schedule
22+
23+
from pyrogram import Client
24+
25+
app = Client("my_account")
26+
27+
28+
def job():
29+
app.send_message("me", "Hi!")
30+
31+
32+
schedule.every(3).seconds.do(job)
33+
34+
with app:
35+
while True:
36+
schedule.run_pending()
37+
time.sleep(1)
38+
39+
40+
41+
Using ``apscheduler``
42+
---------------------
43+
44+
- Install with ``pip3 install apscheduler``
45+
- Documentation: https://apscheduler.readthedocs.io
46+
47+
.. code-block:: python
48+
49+
from apscheduler.schedulers.background import BackgroundScheduler
50+
51+
from pyrogram import Client
52+
53+
app = Client("my_account")
54+
55+
56+
def job():
57+
app.send_message("me", "Hi!")
58+
59+
60+
scheduler = BackgroundScheduler()
61+
scheduler.add_job(job, "interval", seconds=3)
62+
63+
scheduler.start()
64+
app.run()
65+
66+
``apscheduler`` does also support async code, here's an example with
67+
`Pyrogram Asyncio <https://docs.pyrogram.org/intro/install.html#asynchronous>`_:
68+
69+
.. code-block:: python
70+
71+
from apscheduler.schedulers.asyncio import AsyncIOScheduler
72+
73+
from pyrogram import Client
74+
75+
app = Client("my_account")
76+
77+
78+
async def job():
79+
await app.send_message("me", "Hi!")
80+
81+
82+
scheduler = AsyncIOScheduler()
83+
scheduler.add_job(job, "interval", seconds=3)
84+
85+
scheduler.start()
86+
app.run()
87+
File renamed without changes.

0 commit comments

Comments
 (0)