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

Bot API 4.0 #1168

Merged
merged 94 commits into from Aug 29, 2018

Conversation

Projects
None yet
4 participants
@Eldinnie
Copy link
Member

Eldinnie commented Jul 26, 2018

  • Added support for Telegram Passport. See the official announcement on the blog and the manual for details. (#1174)

  • Added support for editing the media content of messages:

    • add shortcut to Message
  • Added the field thumb to the Audio object to contain the thumbnail of the album cover to which the music file belongs. (#1184)

    • Add thumb to Audio
  • Added support for attaching custom thumbnails to uploaded files. For animations, audios, videos and video notes, which are less than 10 MB in size, thumbnails are generated automatically. (#1184)

    • Add thumb to video
    • Add thumb to videonote
  • tg:// URLs now can be used in inline keyboard url buttons and text_link message entities. (no need for change)

  • Added the method sendAnimation, which can be used instead of sendDocument to send animations, specifying their duration, width and height. (#1172)

  • Added the field animation to the Message object. For backward compatibility, when this field is set, the document field will be also set. (#1172)

    • Add animation to Message
    • Maybe rework filters too?
  • Added two new MessageEntity types: cashtag and phone_number. (#1187)

    • add them to MessageEntity
  • Added support for Foursquare venues: (#1170)

    • add the new field foursquare_type to the object Venue
    • add the new field foursquare_type to the object InlineQueryResultVenue
    • add the new field foursquare_type to the object InputVenueMessageContent
    • Add the parameter foursquare_type to the sendVenue method in bot.
  • You can now create inline mentions of users, who have pressed your bot's callback buttons. (no change needed)

  • You can now use the Retry-After response header to configure the delay after which the Bot API will retry the request after an unsuccessful response from a webhook. (Not implemented)

  • Added vCard support when sharing contacts: (#1166)

    • add the field vcard to the object Contact
    • add the field vcard to the object InlineQueryResultContact
    • add the field vcard to the object InputContactMessageContent
    • add the field vcard to the object and the method sendContact in bot.

Closes #1165

'&public_key={}'.format(quote(public_key)) + \
'&payload={}'.format(quote(payload))
if callback_url:
url += '&callback_url={}'.format(escape(callback_url))

This comment has been minimized.

Copy link
@code1mountain

code1mountain Aug 15, 2018

Contributor

escape is not correct here, because we need url encoding, not html escape. quote is the correct function

This comment has been minimized.

Copy link
@jsmnbom

jsmnbom Aug 16, 2018

Member

Indeed, thanks :)

callback_url (:obj:`str`, optional): URL to which the user will be redirected.
"""
url = 'tg://resolve?domain=telegrampassport' + \

This comment has been minimized.

Copy link
@code1mountain

code1mountain Aug 15, 2018

Contributor

A tg://resolve url is no longer clickable on Telegram. We can use t.me/telegrampassport to send a clickable url with the same functionality on telegram. But this url only works on Telegram Desktop.

This comment has been minimized.

Copy link
@jsmnbom

jsmnbom Aug 16, 2018

Member

Any way to do it on mobile at all?

This comment has been minimized.

Copy link
@code1mountain

code1mountain Aug 16, 2018

Contributor

Unfortunately, no. The t.me/telegrampassport url seems more like a bug in the username resolve process of Telegram Desktop. I already contacted Telegram Support and the bot Support. Telegram support didn't know anything about why the links are no longer clickable. Bot support did not reply yet.

This comment has been minimized.

Copy link
@jsmnbom

jsmnbom Aug 19, 2018

Member

@code1mountain Any updates on this?

This comment has been minimized.

Copy link
@jsmnbom

jsmnbom Aug 19, 2018

Member

I'm just gonna remove the function for now. We can always add it in the future if we figure out how to do it properly.
(this should be okay since we haven't released it yet)

"""
url = 'tg://resolve?domain=telegrampassport' + \
'&bot_id={}'.format(bot_id) + \
'&scope={}'.format(quote(scope)) + \

This comment has been minimized.

Copy link
@code1mountain

code1mountain Aug 15, 2018

Contributor

quote somehow doesn't work to escape a list

This comment has been minimized.

Copy link
@jsmnbom

jsmnbom Aug 16, 2018

Member

Yea, we'll probably have to do like ','.join([quote(s) for s in scope]) it seems

digest.update(data)
data_hash = digest.finalize()
if data_hash != hash:
raise TelegramDecryptionError("Hashes are not equal! {} != {}".format(data_hash, hash))

This comment has been minimized.

Copy link
@code1mountain

code1mountain Aug 15, 2018

Contributor

The bot completely hangs up in polling mode if this error occurs, because it is raised when receiving the update and and it can't go on with the other updates. Even a bot restart does not fix it.

This comment has been minimized.

Copy link
@jsmnbom

jsmnbom Aug 16, 2018

Member

Oh that's real bad :/ I'll do some debugging when I get time. Thanks :D I should probably write a test for that error too

This comment has been minimized.

Copy link
@jsmnbom

jsmnbom Aug 19, 2018

Member

I'm not a 100% sure that the test I wrote tests this completely... could you try your test with my latest commits?

jsmnbom added some commits Aug 19, 2018

Warn instead of raise on decryption errors
Should fix updater hanging in these cases
@Eldinnie
Copy link
Member Author

Eldinnie left a comment

Ok so I went over it all.
Made some changes to the docstrings I will push. Some small other changes too.

I think automa(t|g)ically decrypting the passportdata should be done explicit instead of implicit with a previously supplied key. I would like @python-telegram-bot/maintainers opinions on that please.

The docstrings for Passportstuff are still very unclear and copied from one item to another. These need to be fixed. Also the wiki doc needs to be written. (@jsmnbom already had that planned),

Lastly I'[ll try to improve testing. I would prefer the diff to be covered at least 90+%


class SecureData(TelegramObject):
"""
This object represents the credentials required to decrypt encrypted data.

This comment has been minimized.

Copy link
@Eldinnie

Eldinnie Aug 20, 2018

Author Member

This docstrings seems off


class SecureValue(TelegramObject):
"""
This object represents the credentials required to decrypt encrypted value.

This comment has been minimized.

Copy link
@Eldinnie

Eldinnie Aug 20, 2018

Author Member

Same here

@@ -19,6 +19,10 @@
"""This module contains helper functions."""
from html import escape

try:
from urllib import quote # noqa: F401

This comment has been minimized.

Copy link
@Eldinnie

Eldinnie Aug 20, 2018

Author Member

I'm guessing F401 is unused import. But it seems unused. Why is it imported?

This comment has been minimized.

Copy link
@jsmnbom

jsmnbom Aug 21, 2018

Member

Very good question.... removed :)

@@ -0,0 +1,82 @@
#!/usr/bin/env python

This comment has been minimized.

Copy link
@Eldinnie

Eldinnie Aug 20, 2018

Author Member

Regarding the docstrings here. As far as I can see it currently decrypts everything when comming in. So docstrings are off...

@jsmnbom

This comment has been minimized.

Copy link
Member

jsmnbom commented Aug 29, 2018

Merging. Remaining errors are due to non-compliance with official API (missing bot API 4.1).

@jsmnbom jsmnbom merged commit 4689a80 into master Aug 29, 2018

1 of 3 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
continuous-integration/appveyor/pr AppVeyor build failed
Details
Hound No violations found. Woof!

@jsmnbom jsmnbom deleted the bot-api-4.0 branch Sep 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.