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.


🔗 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, never pass them again.

from eztelegramapi import EzTelegramBot

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

msg_id = bot.send_message("Hello from EzTelegramAPI! 🚀")
bot.edit_message(msg_id, "Updated message ✏️")
bot.delete_message(msg_id)
bot.forward_message(from_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

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


Class

EzTelegramBot(token, chat_id=None)

Parameter Type Description
token str Your bot token from @BotFather
chat_id int | None Default chat ID — can be overridden per call

All methods mirror the functions above but without token and with optional chat_id.


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}")

Send to a different chat on the fly:

bot.send_message("Alert!", chat_id=OTHER_CHAT_ID)

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.1.tar.gz (4.3 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.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eztelegramapi-1.0.1.tar.gz
  • Upload date:
  • Size: 4.3 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.1.tar.gz
Algorithm Hash digest
SHA256 e49a2d5d34dba50b7e7b0140d818094e6addb1daf6845220f4023c659fb25f29
MD5 9be92d3f26a4db1b6ca1798472c45263
BLAKE2b-256 f429ba4779a69223905503a5f2ff2f3e385101885d83157f391e4557cd1c0cf6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: eztelegramapi-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c2364ab23e33486e806949e299e23973f608c86495079c2ba47eb5e321adf711
MD5 d944880b8d4a6bcd39ec17db957d70a0
BLAKE2b-256 4946eb3ee155c1030857a3833db83f1ff0ed49eb68e599ddad3dcbdc782a11c3

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