Merge branch 'master' into docs
This commit is contained in:
commit
69351a0728
@ -11,7 +11,7 @@ class {class_name}(Object):
|
|||||||
"""
|
"""
|
||||||
ID = {object_id}
|
ID = {object_id}
|
||||||
|
|
||||||
def __init__(self{arguments}, **kwargs):
|
def __init__(self{arguments}):
|
||||||
{fields}
|
{fields}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
This folder contains example scripts to show you how **Pyrogram** looks like.
|
This folder contains example scripts to show you how **Pyrogram** looks like.
|
||||||
You can start with [hello_world.py](https://github.com/pyrogram/pyrogram/blob/master/examples/hello_world.py) and continue
|
You can start with [hello_world.py](https://github.com/pyrogram/pyrogram/blob/master/examples/hello_world.py) and continue
|
||||||
with the more advanced examples. Every script is working right away (provided you correctly set up your credentials), meaning
|
with the more advanced examples.
|
||||||
|
|
||||||
|
Every script is working right away (provided you correctly set up your credentials), meaning
|
||||||
you can simply copy-paste and run, the only things you have to change are the target chats (username, id) and file paths for
|
you can simply copy-paste and run, the only things you have to change are the target chats (username, id) and file paths for
|
||||||
sending media (photo, video, ...).
|
sending media (photo, video, ...).
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ class Client:
|
|||||||
Thread pool size for handling incoming updates. Defaults to 4.
|
Thread pool size for handling incoming updates. Defaults to 4.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
INVITE_LINK_RE = re.compile(r"^(?:https?://)?(?:t\.me/joinchat/)?([\w-]+)$")
|
INVITE_LINK_RE = re.compile(r"^(?:https?://)?(?:t\.me/joinchat/)([\w-]+)$")
|
||||||
DIALOGS_AT_ONCE = 100
|
DIALOGS_AT_ONCE = 100
|
||||||
UPDATES_WORKERS = 1
|
UPDATES_WORKERS = 1
|
||||||
DOWNLOAD_WORKERS = 1
|
DOWNLOAD_WORKERS = 1
|
||||||
@ -1974,10 +1974,15 @@ class Client:
|
|||||||
Raises:
|
Raises:
|
||||||
:class:`pyrogram.Error`
|
:class:`pyrogram.Error`
|
||||||
"""
|
"""
|
||||||
|
if "Upload" in action.__name__:
|
||||||
|
action = action(progress)
|
||||||
|
else:
|
||||||
|
action = action()
|
||||||
|
|
||||||
return self.send(
|
return self.send(
|
||||||
functions.messages.SetTyping(
|
functions.messages.SetTyping(
|
||||||
peer=self.resolve_peer(chat_id),
|
peer=self.resolve_peer(chat_id),
|
||||||
action=action(progress=progress)
|
action=action
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -2171,14 +2176,21 @@ class Client:
|
|||||||
md5_sum = "".join([hex(i)[2:].zfill(2) for i in md5_sum.digest()])
|
md5_sum = "".join([hex(i)[2:].zfill(2) for i in md5_sum.digest()])
|
||||||
break
|
break
|
||||||
|
|
||||||
session.send(
|
if is_big:
|
||||||
(functions.upload.SaveBigFilePart if is_big else functions.upload.SaveFilePart)(
|
rpc = functions.upload.SaveBigFilePart(
|
||||||
file_id=file_id,
|
file_id=file_id,
|
||||||
file_part=file_part,
|
file_part=file_part,
|
||||||
bytes=chunk,
|
file_total_parts=file_total_parts,
|
||||||
file_total_parts=file_total_parts
|
bytes=chunk
|
||||||
)
|
)
|
||||||
)
|
else:
|
||||||
|
rpc = functions.upload.SaveFilePart(
|
||||||
|
file_id=file_id,
|
||||||
|
file_part=file_part,
|
||||||
|
bytes=chunk
|
||||||
|
)
|
||||||
|
|
||||||
|
assert self.send(rpc), "Couldn't upload file"
|
||||||
|
|
||||||
if is_missing_part:
|
if is_missing_part:
|
||||||
return
|
return
|
||||||
@ -2191,14 +2203,22 @@ class Client:
|
|||||||
if progress:
|
if progress:
|
||||||
progress(min(file_part * part_size, file_size), file_size)
|
progress(min(file_part * part_size, file_size), file_size)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(e)
|
log.error(e, exc_info=True)
|
||||||
else:
|
else:
|
||||||
return (types.InputFileBig if is_big else types.InputFile)(
|
if is_big:
|
||||||
id=file_id,
|
return types.InputFileBig(
|
||||||
parts=file_total_parts,
|
id=file_id,
|
||||||
name=os.path.basename(path),
|
parts=file_total_parts,
|
||||||
md5_checksum=md5_sum
|
name=os.path.basename(path),
|
||||||
)
|
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return types.InputFile(
|
||||||
|
id=file_id,
|
||||||
|
parts=file_total_parts,
|
||||||
|
name=os.path.basename(path),
|
||||||
|
md5_checksum=md5_sum
|
||||||
|
)
|
||||||
finally:
|
finally:
|
||||||
session.stop()
|
session.stop()
|
||||||
|
|
||||||
@ -2318,7 +2338,6 @@ class Client:
|
|||||||
while True:
|
while True:
|
||||||
r2 = cdn_session.send(
|
r2 = cdn_session.send(
|
||||||
functions.upload.GetCdnFile(
|
functions.upload.GetCdnFile(
|
||||||
location=location,
|
|
||||||
file_token=r.file_token,
|
file_token=r.file_token,
|
||||||
offset=offset,
|
offset=offset,
|
||||||
limit=limit
|
limit=limit
|
||||||
|
@ -36,7 +36,7 @@ class Markdown:
|
|||||||
CODE_DELIMITER = "`"
|
CODE_DELIMITER = "`"
|
||||||
PRE_DELIMITER = "```"
|
PRE_DELIMITER = "```"
|
||||||
|
|
||||||
MARKDOWN_RE = re.compile(r"```([\w ]*)\n([\w\W]*)(?:\n|)```|\[(.+)\]\((.+)\)|({d})(.+?)\5".format(
|
MARKDOWN_RE = re.compile(r"```([\w ]*)\n([\w\W]*)(?:\n|)```|\[(.+?)\]\((.+?)\)|({d})(.+?)\5".format(
|
||||||
d="|".join(
|
d="|".join(
|
||||||
["".join(i) for i in [
|
["".join(i) for i in [
|
||||||
["\{}".format(j) for j in i]
|
["\{}".format(j) for j in i]
|
||||||
|
Loading…
Reference in New Issue
Block a user