Skip to content

feat: add document/file forwarding support#382

Closed
AmaLS367 wants to merge 3 commits into
f213:masterfrom
AmaLS367:fix/pdf-document-support
Closed

feat: add document/file forwarding support#382
AmaLS367 wants to merge 3 commits into
f213:masterfrom
AmaLS367:fix/pdf-document-support

Conversation

@AmaLS367

Copy link
Copy Markdown

What

Adds support for forwarding documents (PDF, DOCX, ZIP, and any other file type) sent to the bot as email attachments.

Why

Users were unable to forward files to their inbox. Sending a PDF would result in it being silently ignored by the bot.

Closes #352

How

Added a send_document handler in bot.py following the same pattern as the existing send_photo handler:

  • Fetches the file via Telegram API
  • Downloads it into memory
  • Preserves the original filename from message.document.file_name
  • Dispatches send_file Celery task (already supports arbitrary file attachments)
  • Sends a 👌 reaction on success

Registered with filters.Document.ALL so it catches all document types, not just PDFs.

Changes

  • src/bot.py — new send_document handler + handler registration

Adds a send_document handler that forwards any file sent to the bot
(PDF, DOCX, ZIP, etc.) as an email attachment.

Closes #352
@f213

f213 commented May 28, 2026

Copy link
Copy Markdown
Owner

@AmaLS367 i opened CI workflows for you. After you fix the linters, we can merge this

@AmaLS367

Copy link
Copy Markdown
Author

Fixed the mypy errors by adding an assert. Could you re-approve the CI run? Thanks!

@f213

f213 commented May 28, 2026

Copy link
Copy Markdown
Owner

I re-approved CI, but asserts are not a good idea in the production code. May be we should add a #type: ignore?

@AmaLS367

AmaLS367 commented May 28, 2026

Copy link
Copy Markdown
Author

Okay, thanks. I agree that keeping the assert in production code is not ideal.

I think adding a new # type: ignore here would also be a bit worse, since we already use small typed Update wrappers in this project. I updated it in that style instead: added a typed DocumentMessageUpdate for document messages and changed the handler to use it, so mypy knows message.document exists without a runtime assert.

Could you re-approve the CI run when you have a chance?

@AmaLS367 AmaLS367 closed this by deleting the head repository May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDF not saved :(

2 participants