Skip to main content

Simple Telegram helper

Project description

EzTelegramAPI

Python versions

The simplest way to send Telegram messages from Python.
Four functions. One class. Zero boilerplate. Just send.
Not a bot framework — no receiving, no handlers, no polling.


🔗 GitHub: https://github.com/EmptyOverlord/EzTelegramAPI

📦 PyPI: https://pypi.org/project/eztelegramapi/


Installation

pip install EzTelegramAPI

Two ways to use it

1. Functions — quick and direct

No setup, just call and go. Perfect for one-off scripts and alerts.

from eztelegramapi import send_message, edit_message, delete_message, forward_message

TOKEN   = "123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
CHAT_ID = 987654321

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)

2. Class — no repetition

Set your token and chat_id once — every method uses them automatically.
Pass chat_id= to any method to override for that call only.

from eztelegramapi import EzTelegramBot

bot = EzTelegramBot(token="123456789:AABBCCDDEEFFaabbccddeeff-1234567890", chat_id=987654321)

msg_id = bot.send_message("Hello from EzTelegramAPI! 🚀")  # → sends to 987654321
bot.edit_message(msg_id, "Updated message ✏️")
bot.delete_message(msg_id)

# forward_message uses bot.chat_id as to_chat_id by default
bot.forward_message(from_chat_id=987654322, message_id=msg_id)  # → forwards to 987654321

# override chat_id for a single call
bot.send_message("Alert!", chat_id=OTHER_CHAT_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 Minutes Hours

API Reference

Functions

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 True (default) → returns message_id; False → returns raw requests.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)


Class

EzTelegramBot(token, chat_id=None)

Parameter Type Description
token str Your bot token from @BotFather
chat_id int | None Default chat ID used by all methods — pass chat_id= to any method to override for that call

All methods mirror the functions above but without token.


Examples

Live progress update:

import time

msg_id = bot.send_message("⏳ Job started...")
time.sleep(5)
bot.edit_message(msg_id, "✅ Job finished!")

Clean up after yourself:

msg_id = bot.send_message("⏳ Processing...")
do_work()
bot.delete_message(msg_id)

Alert on error:

try:
    risky_operation()
except Exception as e:
    bot.send_message(f"🔴 Error: {e}")

Cron job notification:

from datetime import datetime

now = datetime.now().strftime("%Y-%m-%d %H:%M")
bot.send_message(f"✅ Backup finished at {now}")

How to get your Chat ID

  1. Start a chat with @userinfobot
  2. Send /start
  3. It replies with your numeric ID — use that as chat_id

License

MIT

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

eztelegramapi-1.0.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eztelegramapi-1.0.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file eztelegramapi-1.0.2.tar.gz.

File metadata

  • Download URL: eztelegramapi-1.0.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for eztelegramapi-1.0.2.tar.gz
Algorithm Hash digest
SHA256 af1513cb1195d6fe9a71dedfb144675ae787720b41839293959820ffae21c653
MD5 8ff11681d20ebba0ecb5fab4b5028d62
BLAKE2b-256 772c3a44176369ad59ca258f8a01184796d2a2e9481968237b5b6cdb7fc5e76b

See more details on using hashes here.

File details

Details for the file eztelegramapi-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: eztelegramapi-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for eztelegramapi-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e6fcee141c1e7fd7192ed6d08fa68eed3db145b833f0480a35a7bd26bac03ee1
MD5 a10cb6345a51f25d3cfd4a269e81c153
BLAKE2b-256 2abf6bd969df501bf75dca867bab225c9d19dcb8e55bdd40ebc61f70ce85422e

See more details on using hashes here.

Supported by

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