Metadata-Version: 2.1
Name: mtproto
Version: 0.1.0b13
Summary: Telegram MTProto protocol implementation
License: MIT
Author: RuslanUC
Author-email: dev_ruslan_uc@protonmail.com
Requires-Python: >=3.9,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Internet
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Provides-Extra: pyaes
Provides-Extra: tgcrypto
Requires-Dist: pyaes (>=1.6.1,<2.0.0) ; extra == "pyaes"
Requires-Dist: tgcrypto (>=1.2.5,<2.0.0) ; extra == "tgcrypto"
Project-URL: Homepage, https://github.com/RuslanUC/mtproto
Project-URL: Repository, https://github.com/RuslanUC/mtproto
Description-Content-Type: text/markdown

# pyMTProto

This is a Telegram MTProto protocol library inspired by [h11](https://github.com/python-hyper/h11).

This library implements the following MTProto transports:
- Abridged
- Intermediate
- Padded Intermediate
- Full
- Obfuscated versions of all above (except Full)

## Installation
```shell
pip install mtproto
```
Note that in order to use obfuscated transports or encrypt/decrypt mtproto messages,
you MUST specify at least one (if you install both, only tgcrypto will be used) 
a crypto library in square brackets (currently tgcrypto and pyaes are supported):
```shell
pip install mtproto[tgcrypto]
```
or 
```shell
pip install mtproto[pyaes]
```

## Usage
```python
from os import urandom

from mtproto import Connection, ConnectionRole
from mtproto.transports import IntermediateTransport
from mtproto.packets import UnencryptedMessagePacket

conn = Connection(
    ConnectionRole.CLIENT,
    # Transport class to use, supported: AbridgedTransport, IntermediateTransport, PaddedIntermediateTransport, FullTransport
    # Default is AbridgedTransport. You need to specify transport class only if you are using ConnectionRole.CLIENT role.
    transport_cls=IntermediateTransport,
    # Whether to use transport obfuscation or not. Default is False. Obfuscation for FullTransport is not supported now. 
    transport_obf=False,
)

to_send = conn.send(UnencryptedMessagePacket(
    message_id=123456789,
    message_data=b"\xbe\x7e\x8e\xf1"[::-1] + urandom(16)  # req_pq_multi#be7e8ef1 nonce:int128
))

# Send data to telegram server
...
# Receive data from telegram server
received = ...
packet = conn.receive(received)

print(packet)
# UnencryptedMessagePacket(message_id=..., message_data=b"...")
```
