Quick Start
Python 3.10+ required. Install using pipx:
pipx install tgpy
tgpy
or Docker:
docker pull tgpy/tgpy
docker run -it --rm -v /tgpy_data:/data tgpy/tgpy
Then follow instructions to connect your Telegram account.
More on installation: https://tgpy.dev/installation
Next, learn TGPy basics: https://tgpy.dev/basics
Use Cases
Here are a few examples of how people use TGPy:
🧮 Run Python as an in-chat calculator
🔍 Search for song lyrics within a chat
🧹 Delete multiple messages with a command
📊 Find out the most active members in a chat
✏️ Instantly convert TeX to Unicode in messages:
For example, x = \alpha^7 becomes x = α⁷
About
TGPy allows you to easily write and execute code snippets directly within your Telegram messages. Combine Telegram features with the full power of Python: Integrate with libraries and APIs. Create functions and TGPy modules to reuse code in the future. Set up code transformers and hooks to create custom commands and tweak Python syntax.
TGPy uses Telegram API through the Telethon library.
Inspiration and Credits
TGPy is inspired by FTG and similar userbots. However, the key concept is different: TGPy is totally based on usage of code in Telegram rather than plugging extra modules. It was designed for running single-use scripts and reusing code flexibly. You can think of TGPy as **a userbot for programmers **.
We built TGPy with Telethon, a Python library to interact with Telegram API. Basic code transformation (such as auto-return of values) is based on meval.
TGPy Docs use Material for MKDocs with custom CSS.
License
This project is licensed under the terms of the MIT license.
Metadata
Release files for tgpy 0.25.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tgpy-0.25.3.tar.gz | 26.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tgpy-0.25.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.4 kB
Release files / tgpy-0.25.3.tar.gz
| Download URL | tgpy-0.25.3.tar.gz |
|---|---|
| Size | 26.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
370761ff9427a1931d9168abd9adbd75491ac5bbf0eb71e31071de06990cefe5
|
|
BLAKE2b-256 checksum How to use checksums |
db6ac911377f75127890a88bc291f672de6e4a119e03dac85e80b31c52f07ca3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.
Transparency logRelease files / tgpy-0.25.3-py3-none-any.whl
| Download URL | tgpy-0.25.3-py3-none-any.whl |
|---|---|
| Size | 34.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2d5bc3ffac83debd541fe2f702d732bac474897be3256fae39c0192946115ab4
|
|
BLAKE2b-256 checksum How to use checksums |
6758f5fc9e7ef8b5dde4a61610556cd0717622c395741f608576a21d47bbca19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.
Transparency log