Skip to main content

Run Python code right in your Telegram messages

Project description

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

Installation

Python 3.9+ is required.

> pip install tgpy
> tgpy

Getting started

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

📒 TGPy Basics

Example

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()

TGPy Guide

Credits

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.4.1.tar.gz (14.6 kB view hashes)

Uploaded Source

Built Distribution

tgpy-0.4.1-py3-none-any.whl (17.9 kB view hashes)

Uploaded Python 3

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