How eternnoir/pytelegrambotapi works
Project type and purpose
• This is an open-source Python client library (“pyTelegramBotAPI”) for the Telegram Bot HTTP API.
• It provides both synchronous (TeleBot) and asynchronous (AsyncTeleBot) interfaces, plus a rich ecosystem of handlers, filters, middleware, storage backends, state managers, utilities, and extensions.
• The examples folder demonstrates usage scenarios (echo bots, webhooks, middleware, serverless, etc.).
File structure
Top level:
• telebot/ ← core library modules
• examples/ ← sample bots and integration patterns
• docs/ ← Sphinx documentation sources
• tests/ ← unit tests against core and types
• config files ← CI (.travis.yml, GitHub Actions), packaging (pyproject.toml, requirements.txt), .gitignore, LICENSE
Inside telebot/:
• apihelper.py ← HTTP adapter (requests for sync, aiohttp for async)
• async_telebot.py ← AsyncTeleBot entry point
• handler_backends.py ← polling & webhook strategy implementations
• asyncio_handler_backends.py ← async equivalents
• custom_filters.py ← base classes for user-defined filters
• formatting.py, util.py ← utility functions (string splitting, update types)
• callback_data.py ← tools for callback‐data parsing
• states/ ← sync & async state management and middleware
• storage/ ← storage strategy interfaces/implementations (memory, pickle, redis)
• types.py ← data model classes mapping Telegram JSON to Python objects
• ext/ ← extensions (reloaders, webhook helpers)
• version.py ← library version
README for architecture hints
• Describes TeleBot vs AsyncTeleBot, middleware patterns, filters, webhook vs polling, storage & state abstractions.
Detailed capture of essential architectural elements
• Filter matching sequence.
• Storage interface abstraction with MemoryStorage, PickleStorage, RedisStorage as implementations.
• Call out ext/webhooks and ext/reloader as opt-in features.