Name | mtproto JSON |
Version |
0.1.0b12
JSON |
| download |
home_page | None |
Summary | Telegram MTProto protocol implementation |
upload_time | 2025-02-10 11:18:38 |
maintainer | None |
docs_url | None |
author | RuslanUC |
requires_python | <4.0,>=3.9 |
license | MIT |
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/2c/5c/3d0b55008974a7bcee07647243618f3ad34a0d49b8206d30e858d76f5fe8/mtproto-0.1.0b12.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.0b12",
"project_urls": {
"Homepage": "https://github.com/RuslanUC/mtproto",
"Repository": "https://github.com/RuslanUC/mtproto"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6c6a24f2855173c15151747c0155e24ad66c096f931f37b419bec5040f6c4fd8",
"md5": "897782718ddbc1de6c7a45cd93c1fd04",
"sha256": "9978533ebecf389c57f69859ba830e9efca41081d48942dbe58b0a6bb1d2521d"
},
"downloads": -1,
"filename": "mtproto-0.1.0b12-py3-none-any.whl",
"has_sig": false,
"md5_digest": "897782718ddbc1de6c7a45cd93c1fd04",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 15737,
"upload_time": "2025-02-10T11:18:37",
"upload_time_iso_8601": "2025-02-10T11:18:37.646577Z",
"url": "https://files.pythonhosted.org/packages/6c/6a/24f2855173c15151747c0155e24ad66c096f931f37b419bec5040f6c4fd8/mtproto-0.1.0b12-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2c5c3d0b55008974a7bcee07647243618f3ad34a0d49b8206d30e858d76f5fe8",
"md5": "964945d7e59a714ab114baf9609e8c83",
"sha256": "15f079d8934f54109b7c961ff8f8be0b2d0471abfafa6725726dd6e1e359b391"
},
"downloads": -1,
"filename": "mtproto-0.1.0b12.tar.gz",
"has_sig": false,
"md5_digest": "964945d7e59a714ab114baf9609e8c83",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 10606,
"upload_time": "2025-02-10T11:18:38",
"upload_time_iso_8601": "2025-02-10T11:18:38.971023Z",
"url": "https://files.pythonhosted.org/packages/2c/5c/3d0b55008974a7bcee07647243618f3ad34a0d49b8206d30e858d76f5fe8/mtproto-0.1.0b12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-10 11:18:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "RuslanUC",
"github_project": "mtproto",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "mtproto"
}