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.2.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.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: osonbot-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 4b8812795b2c6903a01296786b38dbcf8c49abff028b2dbd98da128f984dd7e7
MD5 086d2162a3fa1fd239e3f74a0b2b21ea
BLAKE2b-256 fdff1e989c410cbb6caae41ef306dd849a29188a31ff3c31a588a08ac2e76111

See more details on using hashes here.

File details

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

File metadata

  • Download URL: osonbot-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3f8667a2c216be47b8229d22a29daa45ad000068edc40be5f659a1abb7fd7c73
MD5 04cc19cdcb2ab7695d0a0e6c5fcf0aa3
BLAKE2b-256 b14e39757bd974160f1eeeaa08d51a4d936d556bf7b358e79624dcb9c0f8f5aa

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