Skip to main content

A simple plugin system for pyTelegramBotAPI (telebot)

Project description

TeleBot Plugins

A simple plugin system for pyTelegramBotAPI (telebot) that allows you to organize your bot's functionality into separate plugin files without having to redefine the bot instance in each file.

Features

  • Load plugins from a specified directory
  • Support for both synchronous and asynchronous telebot
  • Handle relative paths properly
  • Automatically register the bot instance globally
  • Support for webhook and polling modes

Installation

pip install telebot-plugins

Usage

Basic Example

from telebot import TeleBot
from telebot_plugins import TelebotWithPlugins

# Create a bot instance
API_TOKEN = "YOUR_BOT_TOKEN"
bot = TeleBot(API_TOKEN)

# Initialize TelebotWithPlugins
plugins = TelebotWithPlugins(
    bot=bot,
    plugins="plugins",  # plugins folder name
    exclude=["disabled_plugin.py"]  # files to exclude (optional)
)

if __name__ == '__main__':
    # Start the bot
    bot.polling()

Example Plugin File (plugins/example.py)

from telebot import bot  # The bot is automatically available

@bot.message_handler(commands=['start'])
def send_welcome(message):
    bot.reply_to(message, "Hello! This is a plugin example.")

Async Bot Example

from telebot.async_telebot import AsyncTeleBot
from telebot_plugins import TelebotWithPlugins
import asyncio

# Create an async bot instance
API_TOKEN = "YOUR_BOT_TOKEN"
bot = AsyncTeleBot(API_TOKEN)

# Initialize TelebotWithPlugins
plugins = TelebotWithPlugins(
    bot=bot,
    plugins="plugins"
)

if __name__ == '__main__':
    # Start the async bot
    asyncio.run(bot.polling())

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

telebot_plugins-0.1.4.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

telebot_plugins-0.1.4-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file telebot_plugins-0.1.4.tar.gz.

File metadata

  • Download URL: telebot_plugins-0.1.4.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for telebot_plugins-0.1.4.tar.gz
Algorithm Hash digest
SHA256 57a6deb78aefda354a92941456aa6a9f28de9248fc77b473409fefe6491e4e53
MD5 13d68da38ffedfae027371831e438267
BLAKE2b-256 93e05cc3ffe26995ddb82d0d9fc0fcd9901173a77eb529f9306fa0d689c484e5

See more details on using hashes here.

File details

Details for the file telebot_plugins-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for telebot_plugins-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1b777d3ee315808aeac892422fd44781babbae162602941b8ea4836f9d90e54a
MD5 7ab61e8e91a16d01231f3bbd0ab5bd0a
BLAKE2b-256 159d197aacc3381153d3e2858fce1c315fab70ce6c13b7652aa195988cd7bc8d

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