64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
"""Server Manager Bot - Main entry point."""
|
|
|
|
import asyncio
|
|
import logging
|
|
import sys
|
|
|
|
from config import (
|
|
load_telegram_config,
|
|
load_qbittorrent_config,
|
|
load_jellyfin_config,
|
|
)
|
|
from services import QbittorrentService, JellyfinService
|
|
from bot import ServerManagerBot
|
|
|
|
|
|
def setup_logging() -> None:
|
|
"""Configure logging for the application."""
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
handlers=[logging.StreamHandler(sys.stdout)],
|
|
)
|
|
|
|
|
|
def main() -> None:
|
|
"""Main entry point."""
|
|
setup_logging()
|
|
logger = logging.getLogger(__name__)
|
|
|
|
try:
|
|
# Load configuration
|
|
telegram_config = load_telegram_config()
|
|
qbittorrent_config = load_qbittorrent_config()
|
|
jellyfin_config = load_jellyfin_config()
|
|
|
|
# Initialize services
|
|
logger.info("Initializing qBittorrent service...")
|
|
qbittorrent_service = QbittorrentService(qbittorrent_config)
|
|
version_info = qbittorrent_service.get_version_info()
|
|
logger.info(f"qBittorrent version: {version_info['version']}")
|
|
|
|
logger.info("Initializing Jellyfin service...")
|
|
jellyfin_service = JellyfinService(jellyfin_config)
|
|
|
|
# Create and run bot
|
|
logger.info("Starting bot...")
|
|
bot = ServerManagerBot(
|
|
telegram_config=telegram_config,
|
|
qbittorrent_service=qbittorrent_service,
|
|
jellyfin_service=jellyfin_service,
|
|
)
|
|
|
|
asyncio.run(bot.run())
|
|
|
|
except KeyboardInterrupt:
|
|
logger.info("Bot stopped by user")
|
|
except Exception as e:
|
|
logger.error(f"Bot failed: {e}", exc_info=True)
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|