Skip to main content

Run Python code right in your Telegram messages

Project description

TGPy

Runs Python code snippets within your Telegram messages

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


Guide: https://tgpy.tmat.me/guide

Recipes: https://tgpy.tmat.me/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.tmat.me/installation

Next, learn TGPy basics: https://tgpy.tmat.me/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.13.1.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

tgpy-0.13.1-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tgpy-0.13.1.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/42.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.7 tqdm/4.66.1 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.13

File hashes

Hashes for tgpy-0.13.1.tar.gz
Algorithm Hash digest
SHA256 085a53a38d6f0af656f9e23a6e0301d0e32da2e54bc727c181456d6a049e6aeb
MD5 f9a0b117f9ccc6575c83eb5045150fe6
BLAKE2b-256 66d5c83a6a922cc008bfb3f9863785b27044b53965620573a7b23b928b4aaf28

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tgpy-0.13.1-py3-none-any.whl
  • Upload date:
  • Size: 28.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/42.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.7 tqdm/4.66.1 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.13

File hashes

Hashes for tgpy-0.13.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5762c5a1fcf6bf6db6b130b30608db82d7e6b837ff843d3b4af4ef114bdc2da4
MD5 eac2908ec2a59f05b6b7ad326d19362b
BLAKE2b-256 859a7628d1fd9d67a6118b0edf88a6dfa5a657ccaee7a9669d8dfa18c3dccb55

See more details on using hashes here.

Supported by

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