Skip to main content

A entirely vibecoded dependency-free Telegram bot library

Project description

vibebot

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

Install

pip install vibecodedbot

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.start()

Run the included example:

Routes

Routes return a Route object. Use .reply(...) for simple replies and .act when you need a function.

bot.on_command("help").reply("Available commands: /start, /help")
bot.on_text("hello").reply("Hi")
bot.on_text("urgent", contains=True).reply("I saw urgent.")
bot.on_media().reply("Got media.")


@bot.on_media("document").act
def handle_document(event):
    return f"Document file id: {event.media.file_id}"

Available route helpers:

  • bot.on_command("start")
  • bot.on_text("hello")
  • bot.on_text("hello", contains=True)
  • bot.on_media()
  • bot.on_media("photo")
  • bot.on_message()
  • bot.on(...) for generic routing

TelegramEvent

Handlers receive a TelegramEvent.

@bot.on_command("start").act
def start(event):
    event.reply(f"Chat id: {event.chat_id}")

Useful properties:

  • event.text
  • event.caption
  • event.command
  • event.chat_id
  • event.message
  • event.update
  • event.media
  • event.media_kind
  • event.photos
  • event.photo

Useful reply helpers:

  • event.reply("text")
  • event.say("text")
  • event.reply_photo(...)
  • event.reply_video(...)
  • event.reply_document(...)
  • event.reply_audio(...)
  • event.reply_voice(...)
  • event.reply_animation(...)
  • event.reply_sticker(...)

Returning a string from an .act handler automatically sends it back to the chat.

Sending Media

bot.send_photo(chat_id, "photo.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.

Media groups are supported with Telegram media dictionaries:

bot.send_media_group(
    chat_id,
    [
        {"type": "photo", "media": "photo-file-id-1"},
        {"type": "photo", "media": "photo-file-id-2"},
    ],
)

Files

file_info = bot.get_file("telegram-file-id")
download_url = bot.file_url("telegram-file-id")

Low-Level API

Bot is available when you want raw Telegram Bot API calls:

from vibebot import Bot

bot = Bot("TOKEN")
result = bot.request("sendMessage", chat_id=123, text="Hello")

Running

These are equivalent polling entry points:

bot.start()
bot.listen()
bot.open()

Exports

Main public exports:

  • VibeBot
  • Bot
  • Route
  • TelegramEvent
  • MediaFile
  • Message
  • Update
  • Chat
  • User
  • TelegramError

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.2.tar.gz (9.9 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.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vibecodedbot-0.1.2.tar.gz
  • Upload date:
  • Size: 9.9 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.2.tar.gz
Algorithm Hash digest
SHA256 2821beaf4309c471380535cbfc765efb86a9083daa0102625ae3895bc0ee126e
MD5 c947134447fc0b7c9b9c2f0a0ad94481
BLAKE2b-256 61252d843c9fc42b8af722d44c798ecb1e5f427c89babb1ffc688f41adb62959

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vibecodedbot-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 98212ded3f8fca3b95622b3772d8313a87029295602ce72ac1bdfe12d864cd1d
MD5 12ab3bc9d6c4ac1d66e2fa2df7998bbc
BLAKE2b-256 550f5aa1beba3824ef2b40e978a2de4056f857c304ceffc9bbc62df533ac3906

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