mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-24 08:14:14 +03:00
Optimize imports
This commit is contained in:
parent
97cab7347b
commit
15fd5390ae
|
@ -4,6 +4,7 @@ try:
|
|||
import rsa
|
||||
import rsa.core
|
||||
except ImportError:
|
||||
rsa = None
|
||||
raise ImportError('Missing module "rsa", please install via pip.')
|
||||
|
||||
from ..extensions import BinaryWriter
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
# Python rough implementation of a C# TCP client
|
||||
import socket
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
from io import BytesIO, BufferedWriter
|
||||
from threading import Event, Lock
|
||||
import errno
|
||||
|
||||
from ..errors import ReadCancelledError
|
||||
import socket
|
||||
from datetime import timedelta
|
||||
from io import BytesIO, BufferedWriter
|
||||
|
||||
|
||||
class TcpClient:
|
||||
|
|
|
@ -118,10 +118,6 @@ class Connection:
|
|||
def close(self):
|
||||
self.conn.close()
|
||||
|
||||
def get_client_delay(self):
|
||||
"""Gets the client read delay"""
|
||||
return self.conn.delay
|
||||
|
||||
# region Receive message implementations
|
||||
|
||||
def recv(self):
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import gzip
|
||||
from threading import RLock, Thread
|
||||
import logging
|
||||
from threading import RLock
|
||||
|
||||
from .. import helpers as utils
|
||||
from ..crypto import AES
|
||||
from ..errors import BadMessageError, InvalidDCError, rpc_message_to_error
|
||||
from ..errors import BadMessageError, rpc_message_to_error
|
||||
from ..extensions import BinaryReader, BinaryWriter
|
||||
from ..tl.all_tlobjects import tlobjects
|
||||
from ..tl.types import MsgsAck
|
||||
from ..extensions import BinaryReader, BinaryWriter
|
||||
|
||||
import logging
|
||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||
|
||||
|
||||
|
|
|
@ -1,43 +1,32 @@
|
|||
import logging
|
||||
from time import sleep
|
||||
from datetime import timedelta
|
||||
from hashlib import md5
|
||||
from os import path
|
||||
from io import BytesIO
|
||||
from os import path
|
||||
|
||||
# Import some externalized utilities to work with the Telegram types and more
|
||||
from . import helpers as utils
|
||||
from .crypto import rsa, CdnDecrypter
|
||||
from .errors import (
|
||||
RPCError, FloodWaitError, FileMigrateError, TypeNotFoundError
|
||||
)
|
||||
from .network import authenticator, MtProtoSender, Connection, ConnectionMode
|
||||
from .utils import get_appropriated_part_size
|
||||
from .crypto import rsa, CdnDecrypter
|
||||
|
||||
# For sending and receiving requests
|
||||
from .tl import TLObject, Session
|
||||
from .tl.all_tlobjects import layer
|
||||
from .tl.functions import (
|
||||
InitConnectionRequest, InvokeWithLayerRequest, PingRequest
|
||||
)
|
||||
|
||||
# Initial request
|
||||
from .tl.functions.help import GetConfigRequest
|
||||
from .tl.functions.auth import (
|
||||
ImportAuthorizationRequest, ExportAuthorizationRequest
|
||||
)
|
||||
|
||||
# Easier access for working with media
|
||||
from .tl.functions.upload import (
|
||||
GetFileRequest, GetCdnFileRequest, ReuploadCdnFileRequest,
|
||||
SaveBigFilePartRequest, SaveFilePartRequest
|
||||
from .tl.functions.help import (
|
||||
GetCdnConfigRequest, GetConfigRequest
|
||||
)
|
||||
from .tl.functions.upload import (
|
||||
GetFileRequest, SaveBigFilePartRequest, SaveFilePartRequest
|
||||
)
|
||||
|
||||
from .tl.functions.help import GetCdnConfigRequest
|
||||
|
||||
# All the types we need to work with
|
||||
from .tl.types import InputFile, InputFileBig
|
||||
from .tl.types.upload import FileCdnRedirect, CdnFileReuploadNeeded
|
||||
from .tl.types.upload import FileCdnRedirect
|
||||
from .utils import get_appropriated_part_size
|
||||
|
||||
|
||||
class TelegramBareClient:
|
||||
|
|
|
@ -1,52 +1,41 @@
|
|||
import os
|
||||
from datetime import datetime, timedelta
|
||||
from mimetypes import guess_type
|
||||
from threading import Event, RLock, Thread
|
||||
from time import sleep, time
|
||||
from threading import RLock, Thread
|
||||
|
||||
from . import TelegramBareClient
|
||||
from .network import ConnectionMode
|
||||
|
||||
# Import some externalized utilities to work with the Telegram types and more
|
||||
from . import helpers as utils
|
||||
from .errors import (RPCError, UnauthorizedError, InvalidParameterError,
|
||||
ReadCancelledError, PhoneCodeEmptyError,
|
||||
from .errors import (
|
||||
RPCError, UnauthorizedError, InvalidParameterError, PhoneCodeEmptyError,
|
||||
PhoneMigrateError, NetworkMigrateError, UserMigrateError,
|
||||
PhoneCodeExpiredError, PhoneCodeHashEmptyError,
|
||||
PhoneCodeInvalidError, InvalidChecksumError)
|
||||
|
||||
# For sending and receiving requests
|
||||
PhoneCodeExpiredError, PhoneCodeHashEmptyError, PhoneCodeInvalidError
|
||||
)
|
||||
from .network import ConnectionMode
|
||||
from .tl import Session, TLObject
|
||||
|
||||
# Required to get the password salt
|
||||
from .tl.functions.account import GetPasswordRequest
|
||||
|
||||
# Logging in and out
|
||||
from .tl.functions.auth import (CheckPasswordRequest, LogOutRequest,
|
||||
SendCodeRequest, SignInRequest,
|
||||
SignUpRequest, ImportBotAuthorizationRequest)
|
||||
|
||||
# Easier access to common methods
|
||||
from .tl.functions.account import (
|
||||
GetPasswordRequest
|
||||
)
|
||||
from .tl.functions.auth import (
|
||||
CheckPasswordRequest, LogOutRequest, SendCodeRequest, SignInRequest,
|
||||
SignUpRequest, ImportBotAuthorizationRequest
|
||||
)
|
||||
from .tl.functions.contacts import (
|
||||
GetContactsRequest, ResolveUsernameRequest
|
||||
)
|
||||
from .tl.functions.messages import (
|
||||
GetDialogsRequest, GetHistoryRequest, ReadHistoryRequest, SendMediaRequest,
|
||||
SendMessageRequest)
|
||||
|
||||
from .tl.functions.contacts import GetContactsRequest, ResolveUsernameRequest
|
||||
|
||||
# For .get_me() and ensuring we're authorized
|
||||
from .tl.functions.users import GetUsersRequest
|
||||
|
||||
# So the server doesn't stop sending updates to us
|
||||
from .tl.functions import PingRequest
|
||||
|
||||
# All the types we need to work with
|
||||
SendMessageRequest
|
||||
)
|
||||
from .tl.functions.users import (
|
||||
GetUsersRequest
|
||||
)
|
||||
from .tl.types import (
|
||||
DocumentAttributeAudio, DocumentAttributeFilename,
|
||||
InputDocumentFileLocation, InputFileLocation,
|
||||
InputMediaUploadedDocument, InputMediaUploadedPhoto, InputPeerEmpty,
|
||||
Message, MessageMediaContact, MessageMediaDocument, MessageMediaPhoto,
|
||||
InputUserSelf, UserProfilePhoto, ChatPhoto)
|
||||
|
||||
InputUserSelf, UserProfilePhoto, ChatPhoto
|
||||
)
|
||||
from .utils import find_user_or_chat, get_extension
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from datetime import datetime, timedelta
|
||||
from threading import Event
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user