-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Bot API 4.0 #1168
Conversation
telegram/utils/helpers.py
Outdated
'&public_key={}'.format(quote(public_key)) + \ | ||
'&payload={}'.format(quote(payload)) | ||
if callback_url: | ||
url += '&callback_url={}'.format(escape(callback_url)) |
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.
escape is not correct here, because we need url encoding, not html escape. quote
is the correct function
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.
Indeed, thanks :)
telegram/utils/helpers.py
Outdated
callback_url (:obj:`str`, optional): URL to which the user will be redirected. | ||
|
||
""" | ||
url = 'tg://resolve?domain=telegrampassport' + \ |
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.
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.
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.
Any way to do it on mobile at all?
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.
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.
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.
@code1mountain Any updates on 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.
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)
telegram/utils/helpers.py
Outdated
""" | ||
url = 'tg://resolve?domain=telegrampassport' + \ | ||
'&bot_id={}'.format(bot_id) + \ | ||
'&scope={}'.format(quote(scope)) + \ |
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.
quote somehow doesn't work to escape a list
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.
Yea, we'll probably have to do like ','.join([quote(s) for s in scope])
it seems
telegram/passport/credentials.py
Outdated
digest.update(data) | ||
data_hash = digest.finalize() | ||
if data_hash != hash: | ||
raise TelegramDecryptionError("Hashes are not equal! {} != {}".format(data_hash, hash)) |
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.
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.
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.
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
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'm not a 100% sure that the test I wrote tests this completely... could you try your test with my latest commits?
Per discussion at: #1168 (review)
Should fix updater hanging in these cases
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.
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+%
telegram/passport/credentials.py
Outdated
|
||
class SecureData(TelegramObject): | ||
""" | ||
This object represents the credentials required to decrypt encrypted data. |
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.
This docstrings seems off
telegram/passport/credentials.py
Outdated
|
||
class SecureValue(TelegramObject): | ||
""" | ||
This object represents the credentials required to decrypt encrypted value. |
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.
Same here
telegram/utils/helpers.py
Outdated
@@ -19,6 +19,10 @@ | |||
"""This module contains helper functions.""" | |||
from html import escape | |||
|
|||
try: | |||
from urllib import quote # noqa: F401 |
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'm guessing F401 is unused import
. But it seems unused. Why is it imported?
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.
Very good question.... removed :)
@@ -0,0 +1,82 @@ | |||
#!/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.
Regarding the docstrings here. As far as I can see it currently decrypts everything when comming in. So docstrings are off...
Merging. Remaining errors are due to non-compliance with official API (missing bot API 4.1). |
Added support for Telegram Passport. See the official announcement on the blog and the manual for details. (Passport #1174)
bot
Added support for editing the media content of messages:
Added the field
thumb
to the Audio object to contain the thumbnail of the album cover to which the music file belongs. (Allow multiple inputfiles in requests #1184)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. (Allow multiple inputfiles in requests #1184)
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. (Animation #1172)
bot
Added the field animation to the Message object. For backward compatibility, when this field is set, the document field will be also set. (Animation #1172)
Message
Added two new MessageEntity types: cashtag and phone_number. (New msg entities #1187)
MessageEntity
Added support for Foursquare venues: (Adding foursquare_type field to Venue #1170)
foursquare_type
to the object Venuefoursquare_type
to the object InlineQueryResultVenuefoursquare_type
to the object InputVenueMessageContentfoursquare_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: (Add vCard field to Contact and related #1166)
Closes #1165