mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-27 20:37:54 +00:00
Merge remote-tracking branch 'origin/develop' into develop
# Conflicts: # pyrogram/client/client.py
This commit is contained in:
commit
e7a85520f2
@ -24,7 +24,7 @@ from . import Bytes
|
||||
class String(Bytes):
|
||||
@staticmethod
|
||||
def read(b: BytesIO, *args) -> str:
|
||||
return super(String, String).read(b).decode()
|
||||
return super(String, String).read(b).decode(errors="replace")
|
||||
|
||||
def __new__(cls, value: str) -> bytes:
|
||||
return super().__new__(cls, value.encode())
|
||||
|
@ -218,28 +218,33 @@ class Client(Methods, BaseClient):
|
||||
self.session.start()
|
||||
self.is_started = True
|
||||
|
||||
if self.user_id is None:
|
||||
try:
|
||||
if self.user_id is None:
|
||||
if self.bot_token is None:
|
||||
self.authorize_user()
|
||||
else:
|
||||
self.authorize_bot()
|
||||
|
||||
self.save_session()
|
||||
|
||||
if self.bot_token is None:
|
||||
self.authorize_user()
|
||||
now = time.time()
|
||||
|
||||
if abs(now - self.date) > Client.OFFLINE_SLEEP:
|
||||
self.peers_by_username = {}
|
||||
self.peers_by_phone = {}
|
||||
|
||||
self.get_initial_dialogs()
|
||||
self.get_contacts()
|
||||
else:
|
||||
self.send(functions.messages.GetPinnedDialogs())
|
||||
self.get_initial_dialogs_chunk()
|
||||
else:
|
||||
self.authorize_bot()
|
||||
|
||||
self.save_session()
|
||||
|
||||
if self.bot_token is None:
|
||||
now = time.time()
|
||||
|
||||
if abs(now - self.date) > Client.OFFLINE_SLEEP:
|
||||
self.peers_by_username = {}
|
||||
self.peers_by_phone = {}
|
||||
|
||||
self.get_initial_dialogs()
|
||||
self.get_contacts()
|
||||
else:
|
||||
self.send(functions.messages.GetPinnedDialogs())
|
||||
self.get_initial_dialogs_chunk()
|
||||
else:
|
||||
self.send(functions.updates.GetState())
|
||||
self.send(functions.updates.GetState())
|
||||
except Exception as e:
|
||||
self.is_started = False
|
||||
self.session.stop()
|
||||
raise e
|
||||
|
||||
for i in range(self.UPDATES_WORKERS):
|
||||
self.updates_workers_list.append(
|
||||
|
@ -35,6 +35,7 @@ class SendAudio(BaseClient):
|
||||
duration: int = 0,
|
||||
performer: str = None,
|
||||
title: str = None,
|
||||
thumb: str = None,
|
||||
disable_notification: bool = None,
|
||||
reply_to_message_id: int = None,
|
||||
reply_markup=None,
|
||||
@ -73,6 +74,12 @@ class SendAudio(BaseClient):
|
||||
title (``str``, *optional*):
|
||||
Track name.
|
||||
|
||||
thumb (``str``, *optional*):
|
||||
Thumbnail of the music file album cover.
|
||||
The thumbnail should be in JPEG format and less than 200 KB in size.
|
||||
A thumbnail's width and height should not exceed 90 pixels.
|
||||
Thumbnails can't be reused and can be only uploaded as a new file.
|
||||
|
||||
disable_notification (``bool``, *optional*):
|
||||
Sends the message silently.
|
||||
Users will receive a notification with no sound.
|
||||
@ -117,10 +124,12 @@ class SendAudio(BaseClient):
|
||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||
|
||||
if os.path.exists(audio):
|
||||
thumb = None if thumb is None else self.save_file(thumb)
|
||||
file = self.save_file(audio, progress=progress, progress_args=progress_args)
|
||||
media = types.InputMediaUploadedDocument(
|
||||
mime_type=mimetypes.types_map.get("." + audio.split(".")[-1], "audio/mpeg"),
|
||||
file=file,
|
||||
thumb=thumb,
|
||||
attributes=[
|
||||
types.DocumentAttributeAudio(
|
||||
duration=duration,
|
||||
|
@ -74,9 +74,10 @@ class SendVideo(BaseClient):
|
||||
Video height.
|
||||
|
||||
thumb (``str``, *optional*):
|
||||
Video thumbnail.
|
||||
Pass a file path as string to send an image that exists on your local machine.
|
||||
Thumbnail should have 90 or less pixels of width and 90 or less pixels of height.
|
||||
Thumbnail of the video sent.
|
||||
The thumbnail should be in JPEG format and less than 200 KB in size.
|
||||
A thumbnail's width and height should not exceed 90 pixels.
|
||||
Thumbnails can't be reused and can be only uploaded as a new file.
|
||||
|
||||
supports_streaming (``bool``, *optional*):
|
||||
Pass True, if the uploaded video is suitable for streaming.
|
||||
|
@ -199,6 +199,7 @@ class Session:
|
||||
i.join()
|
||||
|
||||
self.net_worker_list.clear()
|
||||
self.recv_queue.queue.clear()
|
||||
|
||||
for i in self.results.values():
|
||||
i.event.set()
|
||||
|
Loading…
x
Reference in New Issue
Block a user