Run Python code right in your Telegram messages
Project description
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
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
-
You'll need Telegram API key. Register your "app" at my.telegram.org to get
api_id
andapi_hash
. App title and other data don't matter. -
Clone the repo:
> git clone https://github.com/tm-a-t/TGPy > cd TGPy
-
Create
config.py
. Enter your API data and your phone to log in:api_id = ... api_hash = ... phone = ...
-
Install the requirements and run TGPy:
> pip install -r requirements.txt > python -m tgpy
-
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tgpy-0.2.2.tar.gz
.
File metadata
- Download URL: tgpy-0.2.2.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 817ed80d72f1052c21f55eac3cee04e7aa445d3a39c4cb65d4e85e0023bce276 |
|
MD5 | cec7c2cc4a6495b3ceb785481349b1a0 |
|
BLAKE2b-256 | 8227daa2f8151b449605948a50c18a11aa60af64128b23a92794fff368cc45c9 |
File details
Details for the file tgpy-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: tgpy-0.2.2-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a0ee546b334981a4796dba9edca589baefb6ae73a38163aafdc1fe29b8bdace |
|
MD5 | 37b279157ccff6c973d5bcc6d0a25346 |
|
BLAKE2b-256 | ae2450f1268bf6635095df16d21e5b27da2a7bcc1980f0c2eda3546c9682da3d |