feat: handle Telegram document/file uploads#89
Open
Devail1 wants to merge 1 commit into
Open
Conversation
Add a handler for documents (PDF, etc.) sent to a bound topic: the file is downloaded into ~/.ccbot/documents/ and its path is forwarded to the Claude Code session as '(file attached: <path>)', mirroring how photos are already forwarded. - New handler in handlers/document.py (filters.Document.ALL) - Rejects files over Telegram's 20 MB bot download cap up front, and falls back gracefully if getFile is rejected for an under-reported size - Sanitizes the Telegram-supplied filename before saving - Preserves an optional caption alongside the attached path - Sends a typing indicator but never lets a transient send_action timeout drop the upload before the path reaches tmux Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds support for forwarding documents/files (PDF, etc.) sent in a bound Telegram topic to the Claude Code session — mirroring how photos and voice messages are already handled.
When a user uploads a file to a topic, the bot downloads it into
~/.ccbot/documents/and forwards the saved path to Claude Code as(file attached: <path>)(preserving any caption), so Claude can read it directly.How
handlers/document.py, registered onfilters.Document.ALL.getFileis rejected for an under-reported size.send_actiontimeout drop the upload before the path reaches tmux.Notes
bot.pychanges are minimal: a docstring bullet, the handler import, the registration line, and the "supported message types" string.session_manager,tmux_manager,safe_reply,clear_status_msg_info); no new dependencies.🤖 Generated with Claude Code