Skip to main content

Run Python code right in your Telegram messages

Project description

TGPy

Runs Python code snippets in your Telegram messages

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

> Guide   > Recipes   > Chat


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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tgpy-0.22.0.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tgpy-0.22.0-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

Details for the file tgpy-0.22.0.tar.gz.

File metadata

  • Download URL: tgpy-0.22.0.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tgpy-0.22.0.tar.gz
Algorithm Hash digest
SHA256 6e722332448ddcfb114460054a5e7ea15cc6aec646f21dd00a80de6fceac2fc0
MD5 d4ea56eb67ef4604a8f54f97325c4148
BLAKE2b-256 d9a06bd9f6942793f0cb7011ae873a03501ca0cb82b83831f008b3f4f5478666

See more details on using hashes here.

Provenance

The following attestation bundles were made for tgpy-0.22.0.tar.gz:

Publisher: main.yml on tm-a-t/TGPy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tgpy-0.22.0-py3-none-any.whl.

File metadata

  • Download URL: tgpy-0.22.0-py3-none-any.whl
  • Upload date:
  • Size: 33.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tgpy-0.22.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eaae11389636cf9d72d46462e92647de641ea4a893afe42c4d29a2655fbe4800
MD5 8fc2a11d3737b628b01e565eac49e56a
BLAKE2b-256 c7bc4a3c5ee41648bea40c73e0e50c7d4af8da41c20b6fb8b402bc2d486f60ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for tgpy-0.22.0-py3-none-any.whl:

Publisher: main.yml on tm-a-t/TGPy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page