mtproto


Namemtproto JSON
Version 0.1.0b13 PyPI version JSON
download
home_pageNone
SummaryTelegram MTProto protocol implementation
upload_time2025-09-10 13:27:55
maintainerNone
docs_urlNone
authorRuslanUC
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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"...")
```
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mtproto",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "RuslanUC",
    "author_email": "dev_ruslan_uc@protonmail.com",
    "download_url": "https://files.pythonhosted.org/packages/31/88/9ed25fd98fbc88cc8cde3d27b041e4ec0e0010fb9419d304dc13711c4d8a/mtproto-0.1.0b13.tar.gz",
    "platform": null,
    "description": "# pyMTProto\n\nThis is a Telegram MTProto protocol library inspired by [h11](https://github.com/python-hyper/h11).\n\nThis library implements the following MTProto transports:\n- Abridged\n- Intermediate\n- Padded Intermediate\n- Full\n- Obfuscated versions of all above (except Full)\n\n## Installation\n```shell\npip install mtproto\n```\nNote that in order to use obfuscated transports or encrypt/decrypt mtproto messages,\nyou MUST specify at least one (if you install both, only tgcrypto will be used) \na crypto library in square brackets (currently tgcrypto and pyaes are supported):\n```shell\npip install mtproto[tgcrypto]\n```\nor \n```shell\npip install mtproto[pyaes]\n```\n\n## Usage\n```python\nfrom os import urandom\n\nfrom mtproto import Connection, ConnectionRole\nfrom mtproto.transports import IntermediateTransport\nfrom mtproto.packets import UnencryptedMessagePacket\n\nconn = Connection(\n    ConnectionRole.CLIENT,\n    # Transport class to use, supported: AbridgedTransport, IntermediateTransport, PaddedIntermediateTransport, FullTransport\n    # Default is AbridgedTransport. You need to specify transport class only if you are using ConnectionRole.CLIENT role.\n    transport_cls=IntermediateTransport,\n    # Whether to use transport obfuscation or not. Default is False. Obfuscation for FullTransport is not supported now. \n    transport_obf=False,\n)\n\nto_send = conn.send(UnencryptedMessagePacket(\n    message_id=123456789,\n    message_data=b\"\\xbe\\x7e\\x8e\\xf1\"[::-1] + urandom(16)  # req_pq_multi#be7e8ef1 nonce:int128\n))\n\n# Send data to telegram server\n...\n# Receive data from telegram server\nreceived = ...\npacket = conn.receive(received)\n\nprint(packet)\n# UnencryptedMessagePacket(message_id=..., message_data=b\"...\")\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Telegram MTProto protocol implementation",
    "version": "0.1.0b13",
    "project_urls": {
        "Homepage": "https://github.com/RuslanUC/mtproto",
        "Repository": "https://github.com/RuslanUC/mtproto"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "22a45da2c2a7619aa1df4de20477ef31a1698f9c0a7bafda11cbcbae92532c29",
                "md5": "67463da1b0836ca882b40089c0bd7524",
                "sha256": "d31abdd5f916b61f51e47b4a4afbf888aab734eba4dac343321dd56493ef8712"
            },
            "downloads": -1,
            "filename": "mtproto-0.1.0b13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "67463da1b0836ca882b40089c0bd7524",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 15736,
            "upload_time": "2025-09-10T13:27:54",
            "upload_time_iso_8601": "2025-09-10T13:27:54.237838Z",
            "url": "https://files.pythonhosted.org/packages/22/a4/5da2c2a7619aa1df4de20477ef31a1698f9c0a7bafda11cbcbae92532c29/mtproto-0.1.0b13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "31889ed25fd98fbc88cc8cde3d27b041e4ec0e0010fb9419d304dc13711c4d8a",
                "md5": "7b48105e9762c580c45394586454923f",
                "sha256": "22916d1cac285350d170f8d93a30710f2225b4decae8b9f32548b4e3e3dd2847"
            },
            "downloads": -1,
            "filename": "mtproto-0.1.0b13.tar.gz",
            "has_sig": false,
            "md5_digest": "7b48105e9762c580c45394586454923f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 10601,
            "upload_time": "2025-09-10T13:27:55",
            "upload_time_iso_8601": "2025-09-10T13:27:55.256226Z",
            "url": "https://files.pythonhosted.org/packages/31/88/9ed25fd98fbc88cc8cde3d27b041e4ec0e0010fb9419d304dc13711c4d8a/mtproto-0.1.0b13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-10 13:27:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "RuslanUC",
    "github_project": "mtproto",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "mtproto"
}
        
Elapsed time: 0.45601s