Skip to main content

TGPy

Run Python code right in your Telegram messages

Made with Telethon library, TGPy is a tool for evaluating expressions and Telegram API scripts.

  • Do Python calculations in dialogs
  • Interact with your messages and chats
  • Automate sending messages and more

Example

Just send Python code to any chat, and it will be executed. Change your message to change the result.

Examples

Send any of these examples to any chat to evaluate:

🐍 Do Python calculations

for i in range(5):
    print(i)

⏳ Delete the current message in 5 seconds

import asyncio

await asyncio.sleep(5)
await msg.delete()

↪️ Forward the message you replied to to another chat

orig.forward_to('Chat title')

🖼 Send all chat profile photos to the same chat

photos = await client.get_profile_photos(msg.chat)
msg.reply(file=photos)

🔖 Define a function which forwards messages to Saved Messages with reply

def save():
    message = ctx.msg
    original = await message.get_reply_message()
    await original.forward_to('me')
    return 'Saved!'

🗑 Define a function which deletes messages with reply

async def delete():
    message = ctx.msg
    original = await message.get_reply_message()
    await original.delete()
    await message.delete()

Guide

Installation

  1. You'll need Telegram API key. Register your "app" at my.telegram.org to get api_id and api_hash. App title and other data don't matter.

  2. Clone the repo:

    > git clone https://github.com/tm-a-t/TGPy
    > cd TGPy
    
  3. Create config.py. Enter your API data and your phone to log in:

    api_id = ...
    api_hash = ...
    phone = ...
    
  4. Install the requirements and run TGPy:

    > pip install -r requirements.txt
    > python -m tgpy
    
  5. For the first time, you'll need to log in with a confirmation code from Telegram.

Send ping() to any chat to check if TGPy is running.

Credits

License

This project is licensed under the terms of the MIT license.

Metadata

Release files for tgpy 0.3.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.3.0
File Size Uploaded
tgpy-0.3.0.tar.gz 13.8 kB Details

Built distribution (wheel)

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

Total release size: 30.1 kB

Release files / tgpy-0.3.0.tar.gz

Download URL tgpy-0.3.0.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e2aee79678a49252a68fa1e3f158e58ae6acf7caaa140b9e53b6ecbf94116d38
BLAKE2b-256 checksum
How to use checksums
6d9f822d2afc741588fea7c9cf9c40db3912b0a3308cd200226b6f97fa4d51ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

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

Download URL tgpy-0.3.0-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64290ecea0e9fcd0a666e67dd2c6b5c9dc61c9b8ea1f2dd0429ca454ce54685c
BLAKE2b-256 checksum
How to use checksums
18de1d5d7365cf66a284119c8c6e3c8d389d553f0b3b68afea6cdb037e943e80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

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

0.18.0

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

This release

0.3.0 This release

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