Skip to content

Commit 463ae7d

Browse files
committed
Updated to 1.4.15
Update to 1.4.15 from the latest commit on the official repo https://github.com/pyrogram/pyrogram/
1 parent 481fc26 commit 463ae7d

10 files changed

Lines changed: 41 additions & 45 deletions

File tree

compiler/api/compiler.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
LAYER_RE = re.compile(r"//\sLAYER\s(\d+)")
3535
COMBINATOR_RE = re.compile(r"^([\w.]+)#([0-9a-f]+)\s(?:.*)=\s([\w<>.]+);$", re.MULTILINE)
3636
ARGS_RE = re.compile(r"[^{](\w+):([\w?!.<>#]+)")
37-
FLAGS_RE = re.compile(r"flags\.(\d+)\?")
38-
FLAGS_RE_2 = re.compile(r"flags\.(\d+)\?([\w<>.]+)")
39-
FLAGS_RE_3 = re.compile(r"flags:#")
37+
FLAGS_RE = re.compile(r"flags(\d?)\.(\d+)\?")
38+
FLAGS_RE_2 = re.compile(r"flags(\d?)\.(\d+)\?([\w<>.]+)")
39+
FLAGS_RE_3 = re.compile(r"flags(\d?):#")
4040
INT_RE = re.compile(r"int(\d+)")
4141

4242
CORE_TYPES = ["int", "long", "int128", "int256", "double", "bytes", "string", "Bool", "true"]
@@ -115,7 +115,7 @@ def get_type_hint(type: str) -> str:
115115
type = f"List[{get_type_hint(sub_type)}]"
116116

117117
if is_core:
118-
return f"Union[None, {type}] = None" if is_flag else type
118+
return f"Optional[{type}] = None" if is_flag else type
119119
else:
120120
ns, name = type.split(".") if "." in type else ("", type)
121121
type = f'"raw.base.' + ".".join([ns, name]).strip(".") + '"'
@@ -131,10 +131,9 @@ def sort_args(args):
131131
for i in flags:
132132
args.remove(i)
133133

134-
try:
135-
args.remove(("flags", "#"))
136-
except ValueError:
137-
pass
134+
for i in args[:]:
135+
if re.match(r"flags\d?", i[0]) and i[1] == "#":
136+
args.remove(i)
138137

139138
return args + flags
140139

@@ -362,14 +361,12 @@ def start(format: bool = False):
362361

363362
for i, arg in enumerate(sorted_args):
364363
arg_name, arg_type = arg
365-
is_optional = FLAGS_RE.match(arg_type)
366-
flag_number = is_optional.group(1) if is_optional else -1
367364
arg_type = arg_type.split("?")[-1]
368365

369366
docstring_args.append(
370367
"{}{}: {}".format(
371368
arg_name,
372-
" (optional)".format(flag_number) if is_optional else "",
369+
" (optional)",
373370
get_docstring_arg_type(arg_type, is_pyrogram_type=c.namespace == "pyrogram")
374371
)
375372
)
@@ -401,42 +398,46 @@ def start(format: bool = False):
401398
for arg_name, arg_type in c.args:
402399
flag = FLAGS_RE_2.match(arg_type)
403400

404-
if arg_name == "flags" and arg_type == "#":
401+
if re.match(r"flags\d?", arg_name) and arg_type == "#":
405402
write_flags = []
406403

407404
for i in c.args:
408405
flag = FLAGS_RE_2.match(i[1])
409406

410407
if flag:
411-
if flag.group(2) == "true" or flag.group(2).startswith("Vector"):
412-
write_flags.append(f"flags |= (1 << {flag.group(1)}) if self.{i[0]} else 0")
408+
if arg_name != f"flags{flag.group(1)}":
409+
continue
410+
411+
if flag.group(3) == "true" or flag.group(3).startswith("Vector"):
412+
write_flags.append(f"{arg_name} |= (1 << {flag.group(2)}) if self.{i[0]} else 0")
413413
else:
414-
write_flags.append(f"flags |= (1 << {flag.group(1)}) if self.{i[0]} is not None else 0")
414+
write_flags.append(
415+
f"{arg_name} |= (1 << {flag.group(2)}) if self.{i[0]} is not None else 0")
415416

416417
write_flags = "\n ".join([
417-
"flags = 0",
418+
f"{arg_name} = 0",
418419
"\n ".join(write_flags),
419-
"b.write(Int(flags))\n "
420+
f"b.write(Int({arg_name}))\n "
420421
])
421422

422423
write_types += write_flags
423-
read_types += "flags = Int.read(b)\n "
424+
read_types += f"\n {arg_name} = Int.read(b)\n "
424425

425426
continue
426427

427428
if flag:
428-
index, flag_type = flag.groups()
429+
number, index, flag_type = flag.groups()
429430

430431
if flag_type == "true":
431432
read_types += "\n "
432-
read_types += f"{arg_name} = True if flags & (1 << {index}) else False"
433+
read_types += f"{arg_name} = True if flags{number} & (1 << {index}) else False"
433434
elif flag_type in CORE_TYPES:
434435
write_types += "\n "
435436
write_types += f"if self.{arg_name} is not None:\n "
436437
write_types += f"b.write({flag_type.title()}(self.{arg_name}))\n "
437438

438439
read_types += "\n "
439-
read_types += f"{arg_name} = {flag_type.title()}.read(b) if flags & (1 << {index}) else None"
440+
read_types += f"{arg_name} = {flag_type.title()}.read(b) if flags{number} & (1 << {index}) else None"
440441
elif "vector" in flag_type.lower():
441442
sub_type = arg_type.split("<")[1][:-1]
442443

@@ -447,16 +448,16 @@ def start(format: bool = False):
447448
)
448449

449450
read_types += "\n "
450-
read_types += "{} = TLObject.read(b{}) if flags & (1 << {}) else []\n ".format(
451-
arg_name, f", {sub_type.title()}" if sub_type in CORE_TYPES else "", index
451+
read_types += "{} = TLObject.read(b{}) if flags{} & (1 << {}) else []\n ".format(
452+
arg_name, f", {sub_type.title()}" if sub_type in CORE_TYPES else "", number, index
452453
)
453454
else:
454455
write_types += "\n "
455456
write_types += f"if self.{arg_name} is not None:\n "
456457
write_types += f"b.write(self.{arg_name}.write())\n "
457458

458459
read_types += "\n "
459-
read_types += f"{arg_name} = TLObject.read(b) if flags & (1 << {index}) else None\n "
460+
read_types += f"{arg_name} = TLObject.read(b) if flags{number} & (1 << {index}) else None\n "
460461
else:
461462
if arg_type in CORE_TYPES:
462463
write_types += "\n "

compiler/api/template/combinator.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from io import BytesIO
55
from pyrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector
66
from pyrogram.raw.core import TLObject
77
from pyrogram import raw
8-
from typing import List, Union, Any
8+
from typing import List, Optional, Any
99

1010
{warning}
1111

docs/source/api/decorators.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Index
4040
- :meth:`~Client.on_inline_query`
4141
- :meth:`~Client.on_chosen_inline_result`
4242
- :meth:`~Client.on_chat_member_updated`
43+
- :meth:`~Client.on_chat_join_request`
4344
- :meth:`~Client.on_deleted_messages`
4445
- :meth:`~Client.on_user_status`
4546
- :meth:`~Client.on_poll`
@@ -57,8 +58,9 @@ Details
5758
.. autodecorator:: pyrogram.Client.on_inline_query()
5859
.. autodecorator:: pyrogram.Client.on_chosen_inline_result()
5960
.. autodecorator:: pyrogram.Client.on_chat_member_updated()
61+
.. autodecorator:: pyrogram.Client.on_chat_join_request()
6062
.. autodecorator:: pyrogram.Client.on_deleted_messages()
6163
.. autodecorator:: pyrogram.Client.on_user_status()
6264
.. autodecorator:: pyrogram.Client.on_poll()
6365
.. autodecorator:: pyrogram.Client.on_disconnect()
64-
.. autodecorator:: pyrogram.Client.on_raw_update()
66+
.. autodecorator:: pyrogram.Client.on_raw_update()

pyrogram/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
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-
__version__ = "1.4.12"
19+
__version__ = "1.4.15"
2020
__license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)"
2121
__copyright__ = "Copyright (C) 2017-present Dan <https://github.com/delivrance>"
2222

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 self.loop.create_task(session.send(data))
106+
await session.send(data)
107107
except Exception as e:
108108
log.error(e)
109109

pyrogram/methods/bots/answer_inline_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
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 typing import List
19+
from typing import Iterable
2020

2121
from pyrogram import raw
2222
from pyrogram import types
@@ -27,7 +27,7 @@ class AnswerInlineQuery(Scaffold):
2727
async def answer_inline_query(
2828
self,
2929
inline_query_id: str,
30-
results: List["types.InlineQueryResult"],
30+
results: Iterable["types.InlineQueryResult"],
3131
cache_time: int = 300,
3232
is_gallery: bool = False,
3333
is_personal: bool = False,

pyrogram/methods/bots/send_inline_bot_result.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ async def send_inline_bot_result(
2929
query_id: int,
3030
result_id: str,
3131
disable_notification: bool = None,
32-
reply_to_message_id: int = None,
33-
hide_via: bool = None
32+
reply_to_message_id: int = None
3433
):
3534
"""Send an inline bot result.
3635
Bot results can be retrieved using :meth:`~pyrogram.Client.get_inline_bot_results`
@@ -54,9 +53,6 @@ async def send_inline_bot_result(
5453
reply_to_message_id (``bool``, *optional*):
5554
If the message is a reply, ID of the original message.
5655
57-
hide_via (``bool``):
58-
Sends the message with *via @bot* hidden.
59-
6056
Returns:
6157
:obj:`~pyrogram.types.Message`: On success, the sent inline result message is returned.
6258
@@ -72,7 +68,6 @@ async def send_inline_bot_result(
7268
id=result_id,
7369
random_id=self.rnd_id(),
7470
silent=disable_notification or None,
75-
reply_to_msg_id=reply_to_message_id,
76-
hide_via=hide_via or None
71+
reply_to_msg_id=reply_to_message_id
7772
)
7873
)

pyrogram/methods/chats/join_chat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class JoinChat(Scaffold):
2727
async def join_chat(
2828
self,
2929
chat_id: Union[int, str]
30-
):
30+
) -> "types.Chat":
3131
"""Join a group chat or channel.
3232
3333
Parameters:

pyrogram/raw/core/tl_object.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ def __str__(self) -> str:
5353
return dumps(self, indent=4, default=TLObject.default, ensure_ascii=False)
5454

5555
def __repr__(self) -> str:
56+
if not hasattr(self, "QUALNAME"):
57+
return repr(self)
58+
5659
return "pyrogram.raw.{}({})".format(
5760
self.QUALNAME,
5861
", ".join(

pyrogram/types/messages_and_media/message.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,8 +1671,7 @@ async def reply_inline_bot_result(
16711671
result_id: str,
16721672
quote: bool = None,
16731673
disable_notification: bool = None,
1674-
reply_to_message_id: int = None,
1675-
hide_via: bool = None
1674+
reply_to_message_id: int = None
16761675
) -> "Message":
16771676
"""Bound method *reply_inline_bot_result* of :obj:`~pyrogram.types.Message`.
16781677
@@ -1710,9 +1709,6 @@ async def reply_inline_bot_result(
17101709
reply_to_message_id (``bool``, *optional*):
17111710
If the message is a reply, ID of the original message.
17121711
1713-
hide_via (``bool``):
1714-
Sends the message with *via @bot* hidden.
1715-
17161712
Returns:
17171713
On success, the sent Message is returned.
17181714
@@ -1730,8 +1726,7 @@ async def reply_inline_bot_result(
17301726
query_id=query_id,
17311727
result_id=result_id,
17321728
disable_notification=disable_notification,
1733-
reply_to_message_id=reply_to_message_id,
1734-
hide_via=hide_via
1729+
reply_to_message_id=reply_to_message_id
17351730
)
17361731

17371732
async def reply_location(

0 commit comments

Comments
 (0)