feat: add document/file forwarding support#382
Closed
AmaLS367 wants to merge 3 commits into
Closed
Conversation
Adds a send_document handler that forwards any file sent to the bot (PDF, DOCX, ZIP, etc.) as an email attachment. Closes #352
Owner
|
@AmaLS367 i opened CI workflows for you. After you fix the linters, we can merge this |
Author
|
Fixed the mypy errors by adding an assert. Could you re-approve the CI run? Thanks! |
Owner
|
I re-approved CI, but asserts are not a good idea in the production code. May be we should add a |
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? |
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 (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_documenthandler inbot.pyfollowing the same pattern as the existingsend_photohandler:message.document.file_namesend_fileCelery task (already supports arbitrary file attachments)Registered with
filters.Document.ALLso it catches all document types, not just PDFs.Changes
src/bot.py— newsend_documenthandler + handler registration