Skip to content

Commit e7a8552

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop
# Conflicts: # pyrogram/client/client.py
2 parents edfdf9d + c75a4f1 commit e7a8552

File tree

5 files changed

+37
-21
lines changed

5 files changed

+37
-21
lines changed

pyrogram/api/core/primitives/string.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class String(Bytes):
2525
@staticmethod
2626
def read(b: BytesIO, *args) -> str:
27-
return super(String, String).read(b).decode()
27+
return super(String, String).read(b).decode(errors="replace")
2828

2929
def __new__(cls, value: str) -> bytes:
3030
return super().__new__(cls, value.encode())

pyrogram/client/client.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -218,28 +218,33 @@ def start(self):
218218
self.session.start()
219219
self.is_started = True
220220

221-
if self.user_id is None:
222-
if self.bot_token is None:
223-
self.authorize_user()
224-
else:
225-
self.authorize_bot()
221+
try:
222+
if self.user_id is None:
223+
if self.bot_token is None:
224+
self.authorize_user()
225+
else:
226+
self.authorize_bot()
226227

227-
self.save_session()
228+
self.save_session()
228229

229-
if self.bot_token is None:
230-
now = time.time()
230+
if self.bot_token is None:
231+
now = time.time()
231232

232-
if abs(now - self.date) > Client.OFFLINE_SLEEP:
233-
self.peers_by_username = {}
234-
self.peers_by_phone = {}
233+
if abs(now - self.date) > Client.OFFLINE_SLEEP:
234+
self.peers_by_username = {}
235+
self.peers_by_phone = {}
235236

236-
self.get_initial_dialogs()
237-
self.get_contacts()
237+
self.get_initial_dialogs()
238+
self.get_contacts()
239+
else:
240+
self.send(functions.messages.GetPinnedDialogs())
241+
self.get_initial_dialogs_chunk()
238242
else:
239-
self.send(functions.messages.GetPinnedDialogs())
240-
self.get_initial_dialogs_chunk()
241-
else:
242-
self.send(functions.updates.GetState())
243+
self.send(functions.updates.GetState())
244+
except Exception as e:
245+
self.is_started = False
246+
self.session.stop()
247+
raise e
243248

244249
for i in range(self.UPDATES_WORKERS):
245250
self.updates_workers_list.append(

pyrogram/client/methods/messages/send_audio.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def send_audio(self,
3535
duration: int = 0,
3636
performer: str = None,
3737
title: str = None,
38+
thumb: str = None,
3839
disable_notification: bool = None,
3940
reply_to_message_id: int = None,
4041
reply_markup=None,
@@ -73,6 +74,12 @@ def send_audio(self,
7374
title (``str``, *optional*):
7475
Track name.
7576
77+
thumb (``str``, *optional*):
78+
Thumbnail of the music file album cover.
79+
The thumbnail should be in JPEG format and less than 200 KB in size.
80+
A thumbnail's width and height should not exceed 90 pixels.
81+
Thumbnails can't be reused and can be only uploaded as a new file.
82+
7683
disable_notification (``bool``, *optional*):
7784
Sends the message silently.
7885
Users will receive a notification with no sound.
@@ -117,10 +124,12 @@ def send_audio(self,
117124
style = self.html if parse_mode.lower() == "html" else self.markdown
118125

119126
if os.path.exists(audio):
127+
thumb = None if thumb is None else self.save_file(thumb)
120128
file = self.save_file(audio, progress=progress, progress_args=progress_args)
121129
media = types.InputMediaUploadedDocument(
122130
mime_type=mimetypes.types_map.get("." + audio.split(".")[-1], "audio/mpeg"),
123131
file=file,
132+
thumb=thumb,
124133
attributes=[
125134
types.DocumentAttributeAudio(
126135
duration=duration,

pyrogram/client/methods/messages/send_video.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ def send_video(self,
7474
Video height.
7575
7676
thumb (``str``, *optional*):
77-
Video thumbnail.
78-
Pass a file path as string to send an image that exists on your local machine.
79-
Thumbnail should have 90 or less pixels of width and 90 or less pixels of height.
77+
Thumbnail of the video sent.
78+
The thumbnail should be in JPEG format and less than 200 KB in size.
79+
A thumbnail's width and height should not exceed 90 pixels.
80+
Thumbnails can't be reused and can be only uploaded as a new file.
8081
8182
supports_streaming (``bool``, *optional*):
8283
Pass True, if the uploaded video is suitable for streaming.

pyrogram/session/session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def stop(self):
199199
i.join()
200200

201201
self.net_worker_list.clear()
202+
self.recv_queue.queue.clear()
202203

203204
for i in self.results.values():
204205
i.event.set()

0 commit comments

Comments
 (0)