Skip to main content

Simple Telegram helper

Project description

EzTelegramAPI

Python versions

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

  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.0.tar.gz (4.1 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.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eztelegramapi-1.0.0.tar.gz
  • Upload date:
  • Size: 4.1 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.0.tar.gz
Algorithm Hash digest
SHA256 f47e10ee4fd3d7f61cf31cbf051ad9e1a1128d49f4efd6cb1d354ab0a02d210c
MD5 fb57683fced4ae0d0156a5b2aa21c03f
BLAKE2b-256 2f0fbfab5f49e2dfdc304d2ac103433081b246c524514c2d6e439a8a1bb16833

See more details on using hashes here.

File details

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

File metadata

  • Download URL: eztelegramapi-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 008831e2bcd734259ab3deddb3d3ec2ca76bd7076a056d51d2072fcb9cb1c576
MD5 7674aca8c2777fb9aaf87f4228884dfb
BLAKE2b-256 a924c69fb2fbba75bd8da9a18bafb1537f4b42079620c35a12de8094a5e6beea

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