mtproto


Namemtproto JSON
Version 0.1.4 PyPI version JSON
download
home_pageNone
SummaryTelegram MTProto protocol implementation
upload_time2025-10-28 11:47:28
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/ac/53/856fdca1c8347d3c96c80aece14e5cb407070debdcadcd1b17e3d4fb0d37/mtproto-0.1.4.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.4",
    "project_urls": {
        "Homepage": "https://github.com/RuslanUC/mtproto",
        "Repository": "https://github.com/RuslanUC/mtproto"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "76cdf68b344920ef50bc965135c0d9a748bedc97a21693166ae16e3a9c60b150",
                "md5": "9d7d8b5272f30b4ff9b5fb69172e5e6d",
                "sha256": "6b025c4fb6b2643b4af0678473e4ba7c0afce12a3f180faac2ca0eabcaefc156"
            },
            "downloads": -1,
            "filename": "mtproto-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9d7d8b5272f30b4ff9b5fb69172e5e6d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 16255,
            "upload_time": "2025-10-28T11:47:26",
            "upload_time_iso_8601": "2025-10-28T11:47:26.431235Z",
            "url": "https://files.pythonhosted.org/packages/76/cd/f68b344920ef50bc965135c0d9a748bedc97a21693166ae16e3a9c60b150/mtproto-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac53856fdca1c8347d3c96c80aece14e5cb407070debdcadcd1b17e3d4fb0d37",
                "md5": "b1ab4154332fc0a554cc791e08099f5f",
                "sha256": "8ef2bd953c306650b117242c5f399ea3d9fb51807cbdd1e4faa9f23ccfb4cb83"
            },
            "downloads": -1,
            "filename": "mtproto-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "b1ab4154332fc0a554cc791e08099f5f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 10914,
            "upload_time": "2025-10-28T11:47:28",
            "upload_time_iso_8601": "2025-10-28T11:47:28.768622Z",
            "url": "https://files.pythonhosted.org/packages/ac/53/856fdca1c8347d3c96c80aece14e5cb407070debdcadcd1b17e3d4fb0d37/mtproto-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-28 11:47:28",
    "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: 2.35133s