-
Notifications
You must be signed in to change notification settings - Fork 5.8k
API 5.0 WP4.3: Handling of files in local mode #2223
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
Conversation
Theoretically this is ready for review.
If I get to it before this is reviewed and merged, I'll try to add the |
Update: @Poolitzer tested the local file get & download behaviour on local bot apis on both windows and ubuntu. I just pushed a commit to also allow passing (relative) local paths to send files. Mock-tests succeed (at least locally for me), will double check on ubuntu in a moment. |
Tested |
return False | ||
|
||
path = Path(obj) if isinstance(obj, str) else obj | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need try except here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Path('https://some-domain.org').is_file()
throws an error instead of returning False
…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe so we could do
try:
path.is_file()
return True
except Exception:
return False
thats funny :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah, path.is_file()
can still return False
if the passed string looks like a valid path but the file doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small doc suggestions. Code looks good!
return False | ||
|
||
path = Path(obj) if isinstance(obj, str) else obj | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe so we could do
try:
path.is_file()
return True
except Exception:
return False
thats funny :D
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
# Conflicts: # telegram/files/inputmedia.py
pathlib.Path
objects instead of strings