-
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 3.3 #806
Bot API 3.3 #806
Conversation
|
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 made some comments in the code.
Also I personally would prefer to do the mention a little different. A bit like @bomjacob suggested I would prefer it to be a helper within the telegram.User
object.
So that you get:
user = telegram.User
user.mention_html == "<a href='tg:://user?self.id'>self.name</a>"
Users can then use
message.from_user.mention_markdown
in their code for example.
telegram/chat.py
Outdated
@@ -57,6 +59,8 @@ class Chat(TelegramObject): | |||
Returned only in get_chat. | |||
invite_link (:obj:`str`, optional): Chat invite link, for supergroups and channel chats. | |||
Returned only in get_chat. | |||
pinned_message (:class:`telegram.Message`, optional): Pinned message, for supergroups. | |||
Returned only in getChat. |
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.
Please use get_chat
telegram/chat.py
Outdated
@@ -37,6 +37,8 @@ class Chat(TelegramObject): | |||
photo (:class:`telegram.ChatPhoto`): Optional. Chat photo. | |||
description (:obj:`str`): Optional. Description, for supergroups and channel chats. | |||
invite_link (:obj:`str`): Optional. Chat invite link, for supergroups and channel chats. | |||
pinned_message (:class:`telegram.Message`): Optional. Pinned message, for supergroups. | |||
Returned only in getChat. |
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.
please use get_chat
telegram/utils/helpers.py
Outdated
Optional if User or Message is provided and will overwrite the name in user. | ||
|
||
Returns: | ||
str: |
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.
Please define return as :obj :str
: The inline mention for the user as html or markdown.
telegram/utils/helpers.py
Outdated
if not user: | ||
return None | ||
|
||
if isinstance(user, Message): |
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 would skip this, also see the total review comment.
telegram/utils/helpers.py
Outdated
|
||
elif isinstance(user, User): | ||
if not name: | ||
if user.last_name: |
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 user object already has a name
-property, wouldn;t it make more sense to use that?
https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/user.py#L67
tests/test_message.py
Outdated
order_info={})} | ||
order_info={})}, | ||
{'forward_signature': 'some_forward_sign'}, | ||
{'author_signature': 'some_autohr_sign'} |
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.
Spell mistake (although no big deal in tests, but still.
Hey @jeffffc . Thanks for your work! I made a few adjustment requests in a code comment, Als o please see my suggestion regarding the mention helper. What do you think about that approach? Lastly can you fix the import trouble? So we can see what Travis thinks about it. Pieter |
Let me answer and clarify before pushing updates. Thank you both for your response and I will surely fix the circular import issue. |
@jeffffc you make a good point. I was merely saying that the fallback could be the How about two helper methods within def mention_html(name=None) -> str (<a href ...>)
def mention_markdown(name=None) -> str ([name](...)) |
@Eldinnie sure. |
@jeffffc ouch, ehm, not at pc right now... I can look into it later. |
attempt to fix circular import (not sure if its the correct way tho) added helper methods into User object
The errors in travis tests should not be mine now.
|
you're welcome! |
Looks good, thank you for your work :) |
The tests failing are failing due to sticker trouble. #807 should fix those. |
telegram/user.py
Outdated
:obj:`str`: The inline mention for the user as HTML. | ||
""" | ||
if not name: | ||
return util_mention_html(self.name, self.id) |
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.
You've mixed up arguments. First is user_id
, second is name
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.
you are absolutely right. I mixed up with the old versions. thank you for spotting it out. pushing new commit now.
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.
oops, good spot.
telegram/user.py
Outdated
if not name: | ||
return util_mention_html(self.name, self.id) | ||
else: | ||
return util_mention_html(name, self.id) |
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.
See comment above
Changed the base to 7.1-branch |
🎉 |
just wondering why travis keep saying build is in progress even all tests passed |
@jeffffc I stopped travis to fix an error localy. Will push in a sec.. |
i see, thanks |
I suggest to edit the readme to reflect that API v3.3 is supported |
@alexpacini Good point, although I hope we can skip that and just jump to 3.4 in a few days. |
Bot API 3.3
https://core.telegram.org/bots/api#august-23-2017
added
forward_signature
andauthor-signature
toMessage
added
is_bot
toUser
added
pinned_message
toChat
added
mention()
totelegram.utils.helpers
for easy generation of inline text mentions with (id/User/Message) inputedit: i have no idea why it cannot import
Message
...