mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-18 13:34:54 +00:00
Merge branch 'develop' into asyncio
# Conflicts: # pyrogram/client/client.py # pyrogram/client/methods/messages/send_audio.py # pyrogram/session/session.py
This commit is contained in:
commit
4c290ba38a
@ -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):
|
||||
await 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:
|
||||
await self.authorize_user()
|
||||
else:
|
||||
await self.authorize_bot()
|
||||
|
||||
self.save_session()
|
||||
|
||||
if self.bot_token is None:
|
||||
await self.authorize_user()
|
||||
now = time.time()
|
||||
|
||||
if abs(now - self.date) > Client.OFFLINE_SLEEP:
|
||||
self.peers_by_username = {}
|
||||
self.peers_by_phone = {}
|
||||
|
||||
await self.get_initial_dialogs()
|
||||
await self.get_contacts()
|
||||
else:
|
||||
await self.send(functions.messages.GetPinnedDialogs())
|
||||
await self.get_initial_dialogs_chunk()
|
||||
else:
|
||||
await 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 = {}
|
||||
|
||||
await self.get_initial_dialogs()
|
||||
await self.get_contacts()
|
||||
else:
|
||||
await self.send(functions.messages.GetPinnedDialogs())
|
||||
await self.get_initial_dialogs_chunk()
|
||||
else:
|
||||
await self.send(functions.updates.GetState())
|
||||
await self.send(functions.updates.GetState())
|
||||
except Exception as e:
|
||||
self.is_started = False
|
||||
await self.session.stop()
|
||||
raise e
|
||||
|
||||
self.updates_worker_task = asyncio.ensure_future(self.updates_worker())
|
||||
|
||||
|
@ -35,7 +35,7 @@ class SendAudio(BaseClient):
|
||||
duration: int = 0,
|
||||
performer: str = None,
|
||||
title: str = None,
|
||||
disable_notification: bool = None,
|
||||
thumb: str = None,disable_notification: bool = None,
|
||||
reply_to_message_id: int = None,
|
||||
reply_markup=None,
|
||||
progress: callable = None,
|
||||
@ -73,6 +73,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 +123,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 = await 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.
|
||||
|
@ -27,21 +27,22 @@ try:
|
||||
|
||||
|
||||
class AES:
|
||||
# TODO: Use new tgcrypto function names
|
||||
@classmethod
|
||||
def ige256_encrypt(cls, data: bytes, key: bytes, iv: bytes) -> bytes:
|
||||
return tgcrypto.ige256_encrypt(data, key, iv)
|
||||
return tgcrypto.ige_encrypt(data, key, iv)
|
||||
|
||||
@classmethod
|
||||
def ige256_decrypt(cls, data: bytes, key: bytes, iv: bytes) -> bytes:
|
||||
return tgcrypto.ige256_decrypt(data, key, iv)
|
||||
return tgcrypto.ige_decrypt(data, key, iv)
|
||||
|
||||
@staticmethod
|
||||
def ctr256_encrypt(data: bytes, key: bytes, iv: bytearray, state: bytearray = None) -> bytes:
|
||||
return tgcrypto.ctr256_encrypt(data, key, iv, state or bytearray(1))
|
||||
return tgcrypto.ctr_encrypt(data, key, iv, state or bytearray(1))
|
||||
|
||||
@staticmethod
|
||||
def ctr256_decrypt(data: bytes, key: bytes, iv: bytearray, state: bytearray = None) -> bytes:
|
||||
return tgcrypto.ctr256_decrypt(data, key, iv, state or bytearray(1))
|
||||
return tgcrypto.ctr_decrypt(data, key, iv, state or bytearray(1))
|
||||
|
||||
@staticmethod
|
||||
def xor(a: bytes, b: bytes) -> bytes:
|
||||
|
Loading…
Reference in New Issue
Block a user