Simple Telegram helper
Project description
EzTelegramAPI
The simplest way to send Telegram messages from Python.
Four functions. Zero boilerplate. Just send.
🔗 GitHub: https://github.com/EmptyOverlord/EzTelegramAPI
📦 PyPI: https://pypi.org/project/eztelegramapi/
Installation
pip install EzTelegramAPI
Quickstart
from eztelegramapi import send_message, edit_message, delete_message, forward_message
TOKEN = "123456789:AABBCCDDEEFFaabbccddeeff-1234567890" # from @BotFather
CHAT_ID = 987654321 # your chat ID
msg_id = send_message(TOKEN, CHAT_ID, "Hello from EzTelegramAPI! 🚀")
edit_message(TOKEN, CHAT_ID, msg_id, "Updated message ✏️")
delete_message(TOKEN, CHAT_ID, msg_id)
forward_message(TOKEN, FROM_CHAT_ID=CHAT_ID, TO_CHAT_ID=987654322, MESSAGE_ID=msg_id)
That's it. Seriously.
Why EzTelegramAPI?
| EzTelegramAPI | Other libraries | |
|---|---|---|
| Setup | None | Config, classes, handlers... |
| Lines to send a message | 1 | 5–20+ |
| Dependencies | requests |
Multiple |
| Learning curve | Zero | Non-zero |
API Reference
send_message(token, chat_id, text, *, return_message_id=True)
| Parameter | Type | Description |
|---|---|---|
token |
str |
Your bot token from @BotFather |
chat_id |
int |
Target chat or user ID |
text |
str |
Message text (supports emoji ✅) |
return_message_id |
bool |
If True (default) returns message_id, else raw Response |
Returns: int (message_id) or requests.Response
edit_message(token, chat_id, message_id, text)
| Parameter | Type | Description |
|---|---|---|
token |
str |
Your bot token from @BotFather |
chat_id |
int |
Target chat or user ID |
message_id |
int |
ID of the message to edit |
text |
str |
New message text |
Returns: requests.Response
delete_message(token, chat_id, message_id)
| Parameter | Type | Description |
|---|---|---|
token |
str |
Your bot token from @BotFather |
chat_id |
int |
Target chat or user ID |
message_id |
int |
ID of the message to delete |
Returns: requests.Response
forward_message(token, from_chat_id, to_chat_id, message_id)
| Parameter | Type | Description |
|---|---|---|
token |
str |
Your bot token from @BotFather |
from_chat_id |
int |
Chat to forward the message from |
to_chat_id |
int |
Chat to forward the message to |
message_id |
int |
ID of the message to forward |
Returns: int (message_id of the forwarded message)
Examples
Live progress update:
import time
msg_id = send_message(TOKEN, CHAT_ID, "⏳ Job started...")
time.sleep(5)
edit_message(TOKEN, CHAT_ID, msg_id, "✅ Job finished!")
Clean up after yourself:
msg_id = send_message(TOKEN, CHAT_ID, "⏳ Processing...")
do_work()
delete_message(TOKEN, CHAT_ID, msg_id)
Repost to another chat:
forward_message(TOKEN, FROM_CHAT_ID=CHAT_ID, TO_CHAT_ID=OTHER_CHAT_ID, MESSAGE_ID=msg_id)
Alert on error:
try:
risky_operation()
except Exception as e:
send_message(TOKEN, CHAT_ID, f"🔴 Error: {e}")
Cron job notification:
from datetime import datetime
now = datetime.now().strftime("%Y-%m-%d %H:%M")
send_message(TOKEN, CHAT_ID, f"✅ Backup finished at {now}")
How to get your Chat ID
- Start a chat with @userinfobot
- Send
/start - It replies with your numeric ID — use that as
chat_id
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eztelegramapi-0.4.0.tar.gz.
File metadata
- Download URL: eztelegramapi-0.4.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c0524d5c9fd2e4d62ee4c4c1d738d86c78608607cd666569d1e6ee4fd5f3afd
|
|
| MD5 |
5f3d4309c183cfb64c38300b2b168d3c
|
|
| BLAKE2b-256 |
00bcb5e8edc59baf57fce33e4a631dfc06067680c3e699f593473a1a5fa907c1
|
File details
Details for the file eztelegramapi-0.4.0-py3-none-any.whl.
File metadata
- Download URL: eztelegramapi-0.4.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33419a525fa2e15ba68147e60efc7920628854ea795691c90161d7340efa2d40
|
|
| MD5 |
3ed840ed6d975f6ba60fd5310e7cad18
|
|
| BLAKE2b-256 |
788ba46208c353cbb6ff6102966497dfb5936d1c8a89011c61fe2d1a268ae0dc
|