mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 17:36:34 +03:00
Slightly reorganise the project structure
This commit is contained in:
parent
ba5bfa105f
commit
7adb4f09d6
|
@ -1,7 +1,7 @@
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
|
|
||||||
from .. import helpers as utils
|
from .. import helpers as utils
|
||||||
from ..utils import BinaryReader, BinaryWriter
|
from ..extensions import BinaryReader, BinaryWriter
|
||||||
|
|
||||||
|
|
||||||
class AuthKey:
|
class AuthKey:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
|
|
||||||
from ..utils import BinaryWriter
|
from ..extensions import BinaryWriter
|
||||||
|
|
||||||
|
|
||||||
class RSAServerKey:
|
class RSAServerKey:
|
||||||
|
|
9
telethon/extensions/__init__.py
Normal file
9
telethon/extensions/__init__.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
"""
|
||||||
|
Several extensions Python is missing, such as a proper class to handle a TCP
|
||||||
|
communication with support for cancelling the operation, and an utility class
|
||||||
|
to work with arbitrary binary data in a more comfortable way (writing ints,
|
||||||
|
strings, bytes, etc.)
|
||||||
|
"""
|
||||||
|
from .binary_writer import BinaryWriter
|
||||||
|
from .binary_reader import BinaryReader
|
||||||
|
from .tcp_client import TcpClient
|
|
@ -1,3 +1,4 @@
|
||||||
|
"""Various helpers not related to the Telegram API itself"""
|
||||||
from hashlib import sha1, sha256
|
from hashlib import sha1, sha256
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from .mtproto_plain_sender import MtProtoPlainSender
|
from .mtproto_plain_sender import MtProtoPlainSender
|
||||||
from .tcp_client import TcpClient
|
|
||||||
from .authenticator import do_authentication
|
from .authenticator import do_authentication
|
||||||
from .mtproto_sender import MtProtoSender
|
from .mtproto_sender import MtProtoSender
|
||||||
from .tcp_transport import TcpTransport
|
from .tcp_transport import TcpTransport
|
||||||
|
|
|
@ -5,7 +5,7 @@ from hashlib import sha1
|
||||||
from .. import helpers as utils
|
from .. import helpers as utils
|
||||||
from ..crypto import AES, RSA, AuthKey, Factorization
|
from ..crypto import AES, RSA, AuthKey, Factorization
|
||||||
from ..network import MtProtoPlainSender
|
from ..network import MtProtoPlainSender
|
||||||
from ..utils import BinaryReader, BinaryWriter
|
from ..extensions import BinaryReader, BinaryWriter
|
||||||
|
|
||||||
|
|
||||||
def do_authentication(transport):
|
def do_authentication(transport):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from ..utils import BinaryReader, BinaryWriter
|
from ..extensions import BinaryReader, BinaryWriter
|
||||||
|
|
||||||
|
|
||||||
class MtProtoPlainSender:
|
class MtProtoPlainSender:
|
||||||
|
|
|
@ -8,7 +8,7 @@ from ..errors import (BadMessageError, FloodWaitError,
|
||||||
RPCError, InvalidDCError)
|
RPCError, InvalidDCError)
|
||||||
from ..tl.all_tlobjects import tlobjects
|
from ..tl.all_tlobjects import tlobjects
|
||||||
from ..tl.types import MsgsAck
|
from ..tl.types import MsgsAck
|
||||||
from ..utils import BinaryReader, BinaryWriter
|
from ..extensions import BinaryReader, BinaryWriter
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||||
|
|
|
@ -2,8 +2,8 @@ from binascii import crc32
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from ..errors import InvalidChecksumError
|
from ..errors import InvalidChecksumError
|
||||||
from ..network import TcpClient
|
from ..extensions import TcpClient
|
||||||
from ..utils import BinaryWriter
|
from ..extensions import BinaryWriter
|
||||||
|
|
||||||
|
|
||||||
class TcpTransport:
|
class TcpTransport:
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
"""Utilities for working with TLObjects.
|
"""
|
||||||
We have these because some TLObjects differ in very little things,
|
Utilities for working with the Telegram API itself (such as handy methods
|
||||||
for example, some may have an `user_id` attribute and other a `chat_id` but,
|
to convert between an entity like an User, Chat, etc. into its Input version)
|
||||||
after all, both are the same attribute, IDs."""
|
"""
|
||||||
from mimetypes import add_type, guess_extension
|
from mimetypes import add_type, guess_extension
|
||||||
|
|
||||||
from ..tl.types import (
|
from .tl.types import (
|
||||||
Channel, Chat, ChatPhoto, InputPeerChannel, InputPeerChat, InputPeerUser,
|
Channel, Chat, ChatPhoto, InputPeerChannel, InputPeerChat, InputPeerUser,
|
||||||
MessageMediaDocument, MessageMediaPhoto, PeerChannel, PeerChat, PeerUser,
|
MessageMediaDocument, MessageMediaPhoto, PeerChannel, PeerChat, PeerUser,
|
||||||
User, UserProfilePhoto)
|
User, UserProfilePhoto)
|
|
@ -1,3 +0,0 @@
|
||||||
from .binary_writer import BinaryWriter
|
|
||||||
from .binary_reader import BinaryReader
|
|
||||||
from .tl_utils import *
|
|
|
@ -4,7 +4,8 @@ import threading
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import telethon.network.authenticator as authenticator
|
import telethon.network.authenticator as authenticator
|
||||||
from telethon.network import TcpClient, TcpTransport
|
from telethon.extensions import TcpClient
|
||||||
|
from telethon.network import TcpTransport
|
||||||
|
|
||||||
|
|
||||||
def run_server_echo_thread(port):
|
def run_server_echo_thread(port):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from telethon.utils import BinaryReader, BinaryWriter
|
from telethon.extensions import BinaryReader, BinaryWriter
|
||||||
|
|
||||||
|
|
||||||
class UtilsTests(unittest.TestCase):
|
class UtilsTests(unittest.TestCase):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user