Add t.me links for User, Chat and Message if available and update User.mention_*#1092
Add t.me links for User, Chat and Message if available and update User.mention_*#1092Eldinnie merged 38 commits intopython-telegram-bot:masterfrom jonowo:master
Conversation
Add User.link and update User.mention_*
Add Chat.link
Add Message.link
jsmnbom
left a comment
There was a problem hiding this comment.
I like the idea a lot! Not sure how the other feel yet though. Please see attached comments though.
telegram/chat.py
Outdated
| :attr:`username`, returns a t.me link of the chat. | ||
| """ | ||
| if self.type == "supergroup" and self.username: | ||
| return "t.me/{}".format(self.usermame) |
There was a problem hiding this comment.
Should this default to something? (if it's not a supergroup)
telegram/chat.py
Outdated
| :obj:`str`: Convenience property. If the chat is a supergroup and has a | ||
| :attr:`username`, returns a t.me link of the chat. | ||
| """ | ||
| if self.type == "supergroup" and self.username: |
There was a problem hiding this comment.
Please use the Chat.SUPERGROUP attribute here.
(comment applies elsewhere too)
| if not name: | ||
| return util_mention_markdown(self.id, self.name) | ||
| else: | ||
| if name: |
There was a problem hiding this comment.
This change is out of scope... we're more likely to merge simple self contained pull requests...
IMO this is fine this time though :)
There was a problem hiding this comment.
Will separate into 2 PRs next time.
Eldinnie
left a comment
There was a problem hiding this comment.
Basically the changes look good. Some small comments on docstrings. However tests are missing. Can you please modify/change the tests so they won't fail and diff coverage is 100%
After that we can merge
| """ | ||
| Shortcut for:: | ||
|
|
||
| bot.get_user_profile_photos(update.message.from_user.id, *args, **kwargs) |
There was a problem hiding this comment.
Revert this indent please. Otherwise docs will build weirdly
telegram/user.py
Outdated
| Args: | ||
| name (:obj:`str`): If provided, will overwrite the user's name. | ||
|
|
||
| name (:obj:`str`): If provided, will overwrite the user's full name. |
There was a problem hiding this comment.
Add the blank line between the headers again. Without it docs will mess up.
telegram/user.py
Outdated
| Args: | ||
| name (:obj:`str`): If provided, will overwrite the user's name. | ||
|
|
||
| name (:obj:`str`): If provided, will overwrite the user's full name. |
There was a problem hiding this comment.
Add the blank line between the headers again. Without it docs will mess up.
|
Fixed docstrings. Now working on tests. |
|
@Tr-Jono |
|
Modified tests for user and chat. Will work on |
|
Fixed mistakes, waiting for the checks. I could only work on mobile... |
…p for its link, message links should be available for channels too, fix typos, add more tests for links, confirmed tests passed
Fixed and added more tests, minor change on chat/message link functions
fix docstrings blank lines
|
@jeffffc helped fixed the tests & docstrings, and include links for channels. Should be fine now. ☺ |
|
Hey @Tr-Jono . Did you install the pre-commit hook like explained in our Contributing guide Flake8 found a problem which makes CI fail:
|
|
It was my bad, missed the pre-commit line when I set up a new venv. Will push again a while later, sorry for the silly mistakes we made. |
|
No problem :D |
fix docstrings whitespaces in blank lines
|
Good to go! |
Some docstring formatting. Removed some redundant tests
|
i pushed some last fixes and it's good to go with that IMO. The patch fix being 75% is due to missing tests for |
|
@Tr-Jono one last thing. If you like you can add yourself to the contributers list. EDIT: |
|
Thank you for your contribution |
…r.mention_* (#1092) * Add User.link and update User.mention_* * Add Chat.link * Add Message.link * Link returns None on default * Add test link
…r.mention_* (#1092) * Add User.link and update User.mention_* * Add Chat.link * Add Message.link * Link returns None on default * Add test link
User.link(t.me link of a user if the user has a username)Chat.link(t.me link of a supergroup if it has a username)Message.link(t.me link of a message if it is in a supergroup with a username)Updated
User.mention_markdownandUser.mention_htmlso that the default value ofnameisUser.full_nameinstead ofUser.name. If a user has a username,User.namereturns the user's username prefixed with "@". It makes no sense to markdown a username, since the username already mentions the user.