mtproto


Namemtproto JSON
Version 0.1.0b11 PyPI version JSON
download
home_pageNone
SummaryTelegram MTProto protocol implementation
upload_time2024-12-21 14:19:58
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/ab/41/aaa0b9d48aebcbdb1ab1f0b6ea42413b20968dd422f97fca92aa8720309e/mtproto-0.1.0b11.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.0b11",
    "project_urls": {
        "Homepage": "https://github.com/RuslanUC/mtproto",
        "Repository": "https://github.com/RuslanUC/mtproto"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "16d7594275ed1acd46c9728df72e04311e73a68a6eb41f6b727c26fa753bc546",
                "md5": "86c714a561e214a4ebae3991f5871e65",
                "sha256": "47d2e8cfcd641182c1bb99c2c5c2f50693de04917650df29d54980d202295cc7"
            },
            "downloads": -1,
            "filename": "mtproto-0.1.0b11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "86c714a561e214a4ebae3991f5871e65",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 15340,
            "upload_time": "2024-12-21T14:19:56",
            "upload_time_iso_8601": "2024-12-21T14:19:56.347378Z",
            "url": "https://files.pythonhosted.org/packages/16/d7/594275ed1acd46c9728df72e04311e73a68a6eb41f6b727c26fa753bc546/mtproto-0.1.0b11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ab41aaa0b9d48aebcbdb1ab1f0b6ea42413b20968dd422f97fca92aa8720309e",
                "md5": "f2a2ef39461808350961c74b0ed83181",
                "sha256": "1a2204781c086bd582ee586f98bf42e7c3fd098ad6ba719b15882eaec19d57d9"
            },
            "downloads": -1,
            "filename": "mtproto-0.1.0b11.tar.gz",
            "has_sig": false,
            "md5_digest": "f2a2ef39461808350961c74b0ed83181",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 10317,
            "upload_time": "2024-12-21T14:19:58",
            "upload_time_iso_8601": "2024-12-21T14:19:58.791865Z",
            "url": "https://files.pythonhosted.org/packages/ab/41/aaa0b9d48aebcbdb1ab1f0b6ea42413b20968dd422f97fca92aa8720309e/mtproto-0.1.0b11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-21 14:19:58",
    "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.41522s