Skip to main content

A simple and lightweight Telegram bot framework

Project description

osonbot

A simple Telegram bot framework.

Installation

pip install osonbot

Example echo bot

from osonbot import Bot

bot = Bot("YOUR_BOT_TOKEN")

bot.when("/start", "Hello {first_name}!")
bot.when("*", "{message_text}") # * handles eveymessage if it is a text

bot.run()

Sending Media

from osonbot import Bot, Photo, Video, Audio, Voice, Sticker

bot = Bot("YOUR_BOT_TOKEN")

bot.when("/photo", Photo("https://example.com/cat.jpg", caption="A cute cat 🐱")) 
bot.when("/video", Video("https://example.com/cat.mp4", caption="Funny cat video"))
bot.when("/audio", Audio("https://example.com/sound.mp3", caption="Cat sound"))
bot.when("/voice", Voice("voice.ogg", caption="Voice message"))
bot.when("/sticker", Sticker("CAACAgIAAxkBA..."))

bot.run()

Sending keyboard button

from osonbot import Bot, KeyboardButton

keyboard = KeyboardButton(
    ["Button 1", "Button 2"],
    ["Button 3"],
)

bot = Bot("YOUR_BOT_TOKEN")
bot.when("/start", "Choose an option:", reply_markup=keyboard)
bot.run()

Sending inline keyboard button

from osonbot import InlineKeyboardButton

keyboard = InlineKeyboardButton(
    [["GitHub", "github"], ["Website", "site"]]
)

Sending URL buttons

from osonbot import URLKeyboardButton

keyboard = URLKeyboardButton(
    [["Open GitHub", "https://github.com/sinofarmonov323"]]
)

🧱 Full Features Feature Description ✅ Text message handling when() and c_when() for callbacks 🧩 Inline / Reply keyboards With helper functions 🖼️ Media sending Photo, video, audio, voice, sticker 💾 SQLite integration Auto-create tables 🔍 Logging Built-in logger setup ⚡ Simple formatting Use {first_name}, {message_text}, {user_id} placeholders

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

osonbot-1.0.4.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

osonbot-1.0.4-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file osonbot-1.0.4.tar.gz.

File metadata

  • Download URL: osonbot-1.0.4.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for osonbot-1.0.4.tar.gz
Algorithm Hash digest
SHA256 e88138df3f626df3b352602a9a10202fdae31c297779eb58b0df154ee972e4ae
MD5 83c9dc4c645ed64ba080ce0c79405856
BLAKE2b-256 9a387b4d166f9ba78606861b6f0b6f2bbec8313dcc134a839bdc5c85a64cfebd

See more details on using hashes here.

File details

Details for the file osonbot-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: osonbot-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for osonbot-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0f5f2ab2fa785c114d9bf6ed1ea31fcf822a4e00f0b397bbdca6ce77f27efa0a
MD5 58e362c14ffd43f0c9e4545095b9ed77
BLAKE2b-256 6d0a3462832810df0fa1f4b6e0c61b9821cb299616504eb3ff978fb47a0673f1

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