31 lines
806 B
Python
31 lines
806 B
Python
"""Main bot module."""
|
|
import telebot
|
|
from config import Config
|
|
from database import init_db
|
|
from handlers.group_handlers import register_group_handlers
|
|
from handlers.private_handlers import register_private_handlers
|
|
from handlers.command_handlers import register_command_handlers
|
|
|
|
|
|
def create_bot() -> telebot.TeleBot:
|
|
"""Create and configure the bot."""
|
|
# Validate configuration
|
|
Config.validate()
|
|
|
|
# Ensure BOT_TOKEN is not None
|
|
if not Config.BOT_TOKEN:
|
|
raise ValueError("BOT_TOKEN is required")
|
|
|
|
# Initialize database
|
|
init_db()
|
|
|
|
# Create bot instance
|
|
bot = telebot.TeleBot(Config.BOT_TOKEN)
|
|
|
|
# Register all handlers
|
|
register_group_handlers(bot)
|
|
register_private_handlers(bot)
|
|
register_command_handlers(bot)
|
|
|
|
return bot
|