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.3.tar.gz (5.9 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.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: osonbot-1.0.3.tar.gz
  • Upload date:
  • Size: 5.9 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.3.tar.gz
Algorithm Hash digest
SHA256 ca233abcfd83c070a0c0b4cada535dd5c8ade780d7ee3832fa0a605e40ce993a
MD5 e202a4c017015fae6dd74a90590e8238
BLAKE2b-256 564a441a917087061436d1c503f351023592f15aae869a78418e22a6f46366f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: osonbot-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.2 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5aec3a99931fd45089b23a59f507b7876d11310371c992fedd79ebea1c7ff621
MD5 c2603c0b4e7ce68cbe0db36337b31707
BLAKE2b-256 586ffdc884ee94e1e58c1877093a24d6edccd9975f24218098bdcb1ae8b909f5

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