Skip to content

Commit 86cd819

Browse files
committed
Update Pyrogram to v2.0.33
Update to Pyrogram v2.0.33 from the latest commit on the official repo https://github.com/pyrogram/pyrogram/
1 parent 126dcd3 commit 86cd819

5 files changed

Lines changed: 45 additions & 16 deletions

File tree

compiler/errors/source/400_BAD_REQUEST.tsv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,4 +349,5 @@ WEBDOCUMENT_URL_EMPTY The web document URL is empty
349349
WEBDOCUMENT_URL_INVALID The web document URL is invalid
350350
WEBPAGE_CURL_FAILED Telegram server could not fetch the provided URL
351351
WEBPAGE_MEDIA_EMPTY The URL doesn't contain any valid media
352-
YOU_BLOCKED_USER You blocked this user
352+
YOU_BLOCKED_USER You blocked this user
353+
ENTITY_BOUNDS_INVALID The message entity bounds are invalid

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__ = "2.0.30"
19+
__version__ = "2.0.33"
2020
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
2121
__copyright__ = "Copyright (C) 2017-present Dan <https://github.com/delivrance>"
2222

pyrogram/methods/auth/initialize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ async def initialize(
4444

4545
self.load_plugins()
4646

47-
await self.dispatcher.start()
48-
4947
self.me = await self.get_me()
5048

49+
await self.dispatcher.start()
50+
5151
self.is_initialized = True

pyrogram/methods/messages/edit_inline_media.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,20 @@
1818

1919
import os
2020
import re
21+
import asyncio
2122

2223
import pyrogram
2324
from pyrogram import raw
2425
from pyrogram import types
2526
from pyrogram import utils
27+
from pyrogram.errors import RPCError, MediaEmpty
2628
from pyrogram.file_id import FileType
2729
from .inline_session import get_session
2830

2931

3032
class EditInlineMedia:
33+
MAX_RETRIES = 3
34+
3135
async def edit_inline_media(
3236
self: "pyrogram.Client",
3337
inline_message_id: str,
@@ -147,7 +151,8 @@ async def edit_inline_media(
147151
file_name=os.path.basename(media.media)
148152
),
149153
raw.types.DocumentAttributeAnimated()
150-
]
154+
],
155+
nosound_video=True
151156
)
152157
elif re.match("^https?://", media.media):
153158
media = raw.types.InputMediaDocumentExternal(
@@ -165,7 +170,8 @@ async def edit_inline_media(
165170
raw.types.DocumentAttributeFilename(
166171
file_name=os.path.basename(media.media)
167172
)
168-
]
173+
],
174+
force_file=True
169175
)
170176
elif re.match("^https?://", media.media):
171177
media = raw.types.InputMediaDocumentExternal(
@@ -179,12 +185,34 @@ async def edit_inline_media(
179185

180186
session = await get_session(self, dc_id)
181187

182-
return await session.invoke(
183-
raw.functions.messages.EditInlineBotMessage(
184-
id=unpacked,
185-
media=media,
186-
reply_markup=await reply_markup.write(self) if reply_markup else None,
187-
**await self.parser.parse(caption, parse_mode)
188-
),
189-
sleep_threshold=self.sleep_threshold
188+
actual_media = await self.invoke(
189+
raw.functions.messages.UploadMedia(
190+
peer=raw.types.InputPeerSelf(),
191+
media=media
192+
)
190193
)
194+
195+
for i in range(self.MAX_RETRIES):
196+
try:
197+
return await session.invoke(
198+
raw.functions.messages.EditInlineBotMessage(
199+
id=unpacked,
200+
media=raw.types.InputMediaDocument(
201+
id=raw.types.InputDocument(
202+
id=actual_media.document.id,
203+
access_hash=actual_media.document.access_hash,
204+
file_reference=actual_media.document.file_reference
205+
)
206+
),
207+
reply_markup=await reply_markup.write(self) if reply_markup else None,
208+
**await self.parser.parse(caption, parse_mode)
209+
),
210+
sleep_threshold=self.sleep_threshold
211+
)
212+
except RPCError as e:
213+
if i == self.MAX_RETRIES - 1:
214+
raise
215+
216+
if isinstance(e, MediaEmpty):
217+
# Must wait due to a server race condition
218+
await asyncio.sleep(1)

pyrogram/methods/messages/inline_session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ async def get_session(client: "pyrogram.Client", dc_id: int):
3333

3434
session = client.media_sessions[dc_id] = Session(
3535
client, dc_id,
36-
await Auth(client, dc_id, False).create(),
37-
False, is_media=True
36+
await Auth(client, dc_id, await client.storage.test_mode()).create(),
37+
await client.storage.test_mode(), is_media=True
3838
)
3939

4040
await session.start()

0 commit comments

Comments
 (0)