-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
add support for 3.5 api #920
Conversation
Appearantly TG decided to change the size of a send image (again)
Review wanted. |
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.
Looks really good!
Some small quick notes :)
Then we need to decide if we're gonna release it like this or if we need to get sending new files in groups to work first.
telegram/inputmediaphoto.py
Outdated
if isinstance(media, PhotoSize): | ||
self.media = media.file_id | ||
elif hasattr(media, 'read'): | ||
raise ValueError('We only support file_id or url as a valid media. Sending files is ' |
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.
Maybe add a TODO: about this?
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.
yes, will do
telegram/inputmedia.py
Outdated
@@ -0,0 +1,31 @@ | |||
#!/usr/bin/env python |
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.
Should these files maybe be in files/?
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.
Hmm, maybe.
tests/test_inputmedia.py
Outdated
|
||
def test_with_video(self, video): | ||
# fixture found in test_video | ||
imv = InputMediaVideo(video, caption="test 3") |
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.
I don't think we use abbreviations in the other tests
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.
We don;t and I'm lazy, will fix
assert isinstance(messages, list) | ||
assert len(messages) == 2 | ||
assert all([isinstance(mes, Message) for mes in messages]) | ||
assert all([mes.media_group_id == messages[0].media_group_id for mes in messages]) |
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.
Maybe a TODO: about needing to test with new files.
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.
yup
tests/test_official.py
Outdated
@@ -107,6 +107,8 @@ def check_object(h4): | |||
field = 'from_user' | |||
elif name.startswith('InlineQueryResult') and field == 'type': | |||
continue | |||
elif name.startswith('InputMedia') and field == 'type': |
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.
Could you combine with above?
elif (name.startswith('InlineQueryResult') or name.startswith('InputMedia')) and field == 'type':
seems cleaner to me.
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.
yes, I pondered on it, but I will
assert photo.width == 1920 | ||
assert photo.height == 1080 | ||
assert photo.file_size == 30907 | ||
assert photo.width == 1280 |
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.
What changed here?
And how... like it's a smaller image but it takes up more space? :/
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.
I have no Idea, but it's what came back...
tests/test_official.py
Outdated
elif name.startswith('InlineQueryResult') and field == 'type': | ||
continue | ||
elif name.startswith('InputMedia') and field == 'type': | ||
elif (name.startswith('InlineQueryResult') or name.startswith('InputMedia')) \ |
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.
Could you wrap it all in paranthesis instead of using the backslash here maybe?, doesn't look very clean IMO
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.
👍
Make it possible to send an object that will be json-serialized for send_invoice + tests
As discussed do the current
InputMedia*
throw aValueError
when supplied with a file instead of afile_id
or andurl
.This is because the current workings of
InputFile
and it's mechanics to encode as multipart form data don't support multiple files. And quite frankly, I have no Idea how to do that.Closes #918