Skip to main content

TGPy

Runs Python code snippets within your Telegram messages

PyPI - Downloads PyPI Docker Image Version (latest semver) Open issues Docs


Guide: https://tgpy.dev/guide

Recipes: https://tgpy.dev/recipes

Discussion: https://t.me/tgpy_flood


https://user-images.githubusercontent.com/38432588/181266550-c4640ff1-71f2-4868-ab83-6ea3690c01b6.mp4


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.18.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tgpy 0.18.0
File Size Uploaded
tgpy-0.18.0.tar.gz 24.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tgpy 0.18.0
File Interpreter ABI Platform
tgpy-0.18.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.9 kB

Release files / tgpy-0.18.0.tar.gz

Download URL tgpy-0.18.0.tar.gz
Size 24.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a543d65e7ea746fe3acced5a919ede324120c94fa6bd12d50df7136810df0ebc
BLAKE2b-256 checksum
How to use checksums
8f516d39c603bcf2f1ae31229657d6bd8a276b16726bda397093232bcc3f591a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / tgpy-0.18.0-py3-none-any.whl

Download URL tgpy-0.18.0-py3-none-any.whl
Size 31.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
461f9278c5b3850e6dac62cbea3f02e99098e65a10b95fd2387a1b337116f14f
BLAKE2b-256 checksum
How to use checksums
798640251131437eadc518e7e7ff0eac8060688a9ad39b738d1564c743315bdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

0.25.3

2 release files

0.25.2

2 release files

0.25.1

2 release files

0.25.0

2 release files

0.23.0

2 release files

0.22.1

2 release files

0.22.0

2 release files

0.21.0

2 release files

0.20.1

2 release files

0.20.0

2 release files

0.19.2

2 release files

0.18.1

2 release files

This release

0.18.0 This release

2 release files

0.17.1

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.13.2

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.7

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page