Event Dispatch / MCUB Reload Safety
- Fixed `UpdateMethods.add_event_handler()` so the event type dispatch cache is invalidated instead of being incrementally updated. This prevents reload/install flows from leaving `_event_builders_by_type` non-empty but incomplete after `remove_event_handler()`, which could skip surviving core `NewMessage` handlers.
MCUB Compatibility
- Preserved existing MCUB compatibility changes for dict-style buttons, `invert_media` forwarding, and reply media aliases.
Premium Emoji Support in Buttons
- Added `icon` parameter to all Button helper methods for custom emoji support.
- Supported methods: `Button.inline()`, `Button.switch_inline()`, `Button.url()`, `Button.auth()`, `Button.text()`, `Button.request_location()`, `Button.request_phone()`, `Button.request_poll()`, `Button.buy()`, `Button.game()`.
- The `icon` parameter accepts a Telegram custom emoji document_id (int).
- Requires Telegram Premium on the client side.
Usage:
python
Premium emoji on button
Button.inline("Buy 💎", b"buy", icon=1234567890123456789)
Combination of color and emoji
Button.inline("Confirm ✅", b"confirm", style="success", icon=1234567890123456789)
Works with reply keyboard too
Button.text("Menu", style="primary", icon=1234567890123456789)
Packaging / Distribution
- Unified package metadata around `pyproject.toml` so `setup.py` no longer overrides the fork name, version, Python requirement, and project URLs with upstream Telethon values.
- Fixed requirement file typos in `optional-requirements.txt` and `dev-requirements.txt`.
- Reworked `README.rst` to document installation via `Telethon-MCUB` and the available optional extras.
- Updated issue template and package metadata to point to `Telethon-MCUB` instead of the upstream package.
Security / Protection
- Added configurable protection profiles: `off`, `safe`, `strict`, and `custom`.
- Added `ProtectionPolicy` and `ProtectionViolation` primitives for request inspection and policy-driven blocking.
- Added client-side protection controls: `protection_mode`, `get_protection_policy()`, `set_protection_policy()`, `set_protection_mode()`, `on_blocked_request()`, and `clear_blocked_request_handler()`.
- Added `dry_run` and allowlist overrides so blocked requests can be observed without being rejected.
Forum Topics
- Added high-level topic helpers: `iter_topics()`, `get_topics()`, `get_topic()`, `create_topic()`, `edit_topic()`, `close_topic()`, `reopen_topic()`, `delete_topic_history()`, `pin_topic()`, `reorder_topics()`, `iter_topic_messages()`, `send_to_topic()`, and `send_file_to_topic()`.
- Added topic-aware message sending via `topic=` in `send_message()` and `send_file()`.
- Added topic-aware history iteration: `iter_messages(..., topic=...)` now fetches a single forum thread, and topic-scoped search uses `messages.Search` with `top_msg_id`.
History Export
- Added `iter_history_batches()` for grouped history processing on top of `iter_messages()`.
- Added `export_history()` to write JSONL exports with chronological mode by default, optional media downloading, and resumable state files.
- Added `HistoryExportResult` so export jobs can report exported message count, downloaded media count, and the last exported message ID.
Middleware
- Added request middleware support around `TelegramClient.__call__()` via `add_request_middleware()`, `remove_request_middleware()`, and `request_middleware()`.
- Added `RequestContext` metadata for middleware chains, including `attempt`, `ordered`, `flood_sleep_threshold`, `started_at`, `sender`, and batch/original request information.
- Added explicit `add_event_middleware()` and `remove_event_middleware()` helpers while keeping `client.middleware(...)` as a backward-compatible decorator alias.
Transfers
- Added resumable file downloads via `download_file(..., resume=True, resume_key=..., state_store=...)`.
- Added resumable `download_media()` support for Telegram-hosted document and photo downloads.
- Added `FileTransferState` and `JsonTransferStateStore` primitives for persisting transfer checkpoints between runs.
- Added resumable uploads via `upload_file(..., resume=True, resume_key=..., state_store=...)`.
- Added single-file `send_file()` / `send_message(file=...)` support for resumable uploads, with album uploads explicitly excluded from resume mode for now.