Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: the ability to receive photo/document messages and download files #2

Merged
merged 12 commits into from
Jul 8, 2023

Conversation

DanArmor
Copy link
Contributor

@DanArmor DanArmor commented Jul 7, 2023

Added

  • PhotoSize, File and Document types according to telegram-api
  • get_file function to get File object and download_file to download file by file_path from File
  • photo and document fields for message
  • photo and document methods for update similar to text
  • Matcher for Photo and Document messages changed match_update how it handles Message to catch photo/document messages, changed Matcher::match_str to return false on Photo and Document
  • added examples - simple bots. One downloads sent files, the other downloads sent photos

Notes:

I was not sure, how to handle downloading, because we need to use https://api.telegram.org/file/bot<token>/<file_path> and not a base_url, and also there is no json-body in request - so I made a download_file method for Client.

@0xfe
Copy link
Owner

0xfe commented Jul 7, 2023

Thanks for the PR. Downloading is a bit of an outlier, and this approach looks fine for now. See minor nitpick.

src/lib/router.rs Show resolved Hide resolved
@DanArmor DanArmor requested a review from 0xfe July 7, 2023 20:27
@0xfe 0xfe merged commit 9cb9f32 into 0xfe:main Jul 8, 2023
1 check passed
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.

None yet

2 participants