Allow edited as seperate input#608
Conversation
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
| 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') |
There was a problem hiding this comment.
I think you should put a line below such as this:
edited_updates = allow_editedThere was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
You are indeed right... I'm sorry, I had the arguments flipped around in my head
telegram/ext/messagehandler.py
Outdated
| @@ -80,6 +86,7 @@ def __init__(self, | |||
| self.allow_edited = allow_edited | |||
There was a problem hiding this comment.
... and then you can remove this line
telegram/ext/messagehandler.py
Outdated
| 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), |
|
This makes sense. will do |
|
Maybe you should make |
|
They don't really need to be, if one of them is deprecated already |
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.
fixes #607