Skip to main content

A entirely vibecoded dependency-free Telegram bot library

Project description

vibebot

A small dependency-free Python Telegram bot library with a route-based syntax.

Quick start

import os

from vibebot import VibeBot

bot = VibeBot(os.environ["TELEGRAM_BOT_TOKEN"])

bot.on_command("start").reply("Hello from vibebot.")
bot.on_text("ping", contains=True).reply("pong")
bot.on_media("photo").reply("Nice photo.")


@bot.on_message().act
def echo(event):
    return event.text


bot.open()

Run the included example:

$env:TELEGRAM_BOT_TOKEN = "123456:your-token"
python examples_echo.py

Syntax

  • bot.on_command("start").reply("Hello") handles /start.
  • bot.on_text("ping", contains=True).reply("pong") matches message text.
  • @bot.on_message().act runs custom code for every message.
  • Handler functions receive a TelegramEvent.
  • Returning a string from a handler automatically sends it back.

TelegramEvent helpers

  • event.text
  • event.caption
  • event.command
  • event.chat_id
  • event.media
  • event.media_kind
  • event.photo
  • event.reply("text")
  • event.reply_photo("photo-file-id-or-path.jpg", caption="Look")
  • event.reply_document("report.pdf")

The lower-level Bot class is still available for raw Telegram Bot API calls.

Sending Media

bot.send_photo(chat_id, "photo-file-id-or-path.jpg", caption="Photo")
bot.send_video(chat_id, "video.mp4", caption="Video")
bot.send_document(chat_id, "report.pdf")
bot.send_audio(chat_id, "song.mp3")
bot.send_voice(chat_id, "voice.ogg")
bot.send_animation(chat_id, "animation.gif")
bot.send_sticker(chat_id, "sticker-file-id")

Media values can be Telegram file_ids, public URLs, local paths, Path objects, or open binary file objects.

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

vibecodedbot-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

vibecodedbot-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file vibecodedbot-0.1.0.tar.gz.

File metadata

  • Download URL: vibecodedbot-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for vibecodedbot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 30ef26d8cb2b5c79e9987c2bc2fc437e7721a42085dc767a043eed6d61474156
MD5 acd0a75a5d3a48872a739fae376b0897
BLAKE2b-256 e8470ca325e8151cf68b4e2637ca6bef00d2487d7b1b46f973b144e8eaa62c8f

See more details on using hashes here.

File details

Details for the file vibecodedbot-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: vibecodedbot-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for vibecodedbot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca93fdb9ecdfcf8b47a83c435a293f6b1e096aa8fafb9e800935199bf59407fb
MD5 7a24ab5fd17fe8d8fb26670ad3189bcf
BLAKE2b-256 ab8bb207066dfe1af698b776387ef51e309ef7bd7e3434d4e6dd4908633ee9d8

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