Skip to main content

A simple telegram bot api

Project description

Simple Telegram Bot

A simple and easy-to-use Python library for Telegram bots. This library allows you to send messages, edit messages, fetch updates, and handle messages easily.

Installation

Installation using pip (a Python package manager):

pip install simple-telegram-api

Example

A simple echo bot:

from simple_telegram_api import TelegramBot

BOT_TOKEN = "BOT_TOKEN"

bot = TelegramBot(BOT_TOKEN)

# Skip old messages before bot is running.
bot.reset_updates()

print("Bot is running.")
while True:
    updates = bot.get_updates()

    # Check if it's empty.
    if updates:
        print(updates)
        bot.reset_updates(updates=updates)

        # For multiple coming up messages.
        for update in updates["result"]:
            chat_id = update["message"]["chat"]["id"]
            message_id = update["message"]["message_id"]
            user_text = update["message"]["text"]
            
            bot_message = bot.send_message(chat_id=chat_id, text=user_text)

Recommendations

If updates is not provided in reset_updates(), new updates will be fetched automatically. Use the result from get_updates() as updates, as shown in the example.

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

simple_telegram_api-0.1.6.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

simple_telegram_api-0.1.6-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file simple_telegram_api-0.1.6.tar.gz.

File metadata

  • Download URL: simple_telegram_api-0.1.6.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for simple_telegram_api-0.1.6.tar.gz
Algorithm Hash digest
SHA256 bbc2b254697eab505846f854bc0f25726eb2c5e740b4a5fe6eeb807890b53c62
MD5 da87883a202df85f7034115dd7f95cf0
BLAKE2b-256 02e1397ae79a1ca3a17a875a03c64273aeb8d5846c0d73a924a1f240b13e2c1a

See more details on using hashes here.

File details

Details for the file simple_telegram_api-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_telegram_api-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b2fad5f3c585fe83eed5d185bbc73a8cead1091be8bdfddd8c23668c909eb214
MD5 0ca7c183eab31a456d69d40db4f33255
BLAKE2b-256 287350a8877293ba365fdbe414b5d425fba7faab98b63bbe94e765306fd1d3a3

See more details on using hashes here.

Supported by

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