X Tutup
Skip to content

Allow edited as seperate input#608

Merged
jh0ker merged 4 commits intopython-telegram-bot:masterfrom
Eldinnie:Issue_607
May 19, 2017
Merged

Allow edited as seperate input#608
jh0ker merged 4 commits intopython-telegram-bot:masterfrom
Eldinnie:Issue_607

Conversation

@Eldinnie
Copy link
Copy Markdown
Member

@Eldinnie Eldinnie commented May 15, 2017

In short made it possible to tune messagehandler more to your wishes. and choose exactly what updates to receive. messages, edited_message or channel_post or a combination.

  • Added the edited_updates argument to MessageHandler
  • Added DeprecationWarning when using allow_edited
  • replaced _is_allowed_message and _is_allowed_channel_post with _is_allowed_update
  • Modified tests to reflect new way

fixes #607

Eldinnie added 3 commits May 15, 2017 22:13
In short made it possible to tune messagehandler more to your wishes. and choose exactly what updates to receive. messages, edited_message or channel_post or a combination.

- Added the edited_updates argument to MessageHandler
- Added DepricationWarning when using allow_edited
- replaced _is_allowed_message and _is_allowed_channel_post with _is_allowed_update
- Modified tests to reflect new way
Spelled deprecation wrong
made an error in the _is_allowed_update.
raise ValueError(
'message_updates, channel_post_updates and edited_updates are all False')
if allow_edited:
warnings.warn('allow_edited is getting deprecated, please use edited_updates instead')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should put a line below such as this:

edited_updates = allow_edited

Copy link
Copy Markdown
Member

@jsmnbom jsmnbom May 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't... if you rename an argument, then it is sooo much nicer to also rename the attribute in the class while you are at it. Then in the future when we wanna remove the deprecated stuff, we don't have to change a ton of stuff.
So well... do what @evgfilim1 is suggesting, just the other way around :D

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not renaming an argument, I'm adding behavior and warning the old behavior is going to be deprecated.
What you suggest would be valid if allow_edited would reflect the change but it doesn't.
If I do it this way, it will implement the new functionality and still work with the old way. If you want to remove the deprecated way in the future you need to remove three lines in the code instead of removing thee and modifying two.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are indeed right... I'm sorry, I had the arguments flipped around in my head

@@ -80,6 +86,7 @@ def __init__(self,
self.allow_edited = allow_edited
Copy link
Copy Markdown
Contributor

@evgfilim1 evgfilim1 May 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and then you can remove this line

and (update.channel_post or (update.edited_channel_post and self.allow_edited)))
def _is_allowed_update(self, update):
return any([(self.message_updates and update.message),
(self.allow_edited and update.edited_message),
Copy link
Copy Markdown
Contributor

@evgfilim1 evgfilim1 May 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and this one

@Eldinnie
Copy link
Copy Markdown
Member Author

This makes sense. will do

@evgfilim1
Copy link
Copy Markdown
Contributor

Maybe you should make allow_edited and edited_updates mutually exclusive?

@jsmnbom
Copy link
Copy Markdown
Member

jsmnbom commented May 18, 2017

They don't really need to be, if one of them is deprecated already

@jh0ker jh0ker merged commit e2a651a into python-telegram-bot:master May 19, 2017
@github-actions github-actions bot locked and limited conversation to collaborators Aug 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add ability to handle only edited messages updates

4 participants

X Tutup