We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
add ability to handle only edited messages updates
Actually if you want to develop a bot where when a user edits his message it replies "you edited this message" or a bot that in groups kicks users that edit their messages (let's imagine a strange rule), there is not a handler to handle only edited messages.

messagehandler just handles any messages and not only those edited. So a handler or a filter to handle only edited messages is needed. Thanks




--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `telegram/ext/messagehandler.py`
Content:
```
1 #!/usr/bin/env python
2 #
3 # A library that provides a Python interface to the Telegram Bot API
4 # Copyright (C) 2015-2017
5 # Leandro Toledo de Souza <devs@python-telegram-bot.org>
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Lesser Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU Lesser Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser Public License
18 # along with this program.  If not, see [http://www.gnu.org/licenses/].
19 """ This module contains the MessageHandler class """
20 import warnings
21 
22 from .handler import Handler
23 from telegram import Update
24 
25 
26 class MessageHandler(Handler):
27     """
28     Handler class to handle telegram messages. Messages are Telegram Updates
29     that do not contain a command. They might contain text, media or status
30     updates.
31 
32     Args:
33         filters (telegram.ext.BaseFilter): A filter inheriting from
34             :class:`telegram.ext.filters.BaseFilter`. Standard filters can be found in
35             :class:`telegram.ext.filters.Filters`. Filters can be combined using bitwise
36             operators (& for and, | for or).
37         callback (function): A function that takes ``bot, update`` as
38             positional arguments. It will be called when the ``check_update``
39             has determined that an update should be processed by this handler.
40         allow_edited (Optional[bool]): If the handler should also accept edited messages.
41             Default is ``False``
42         pass_update_queue (optional[bool]): If the handler should be passed the
43             update queue as a keyword argument called ``update_queue``. It can
44             be used to insert updates. Default is ``False``
45         pass_user_data (optional[bool]): If set to ``True``, a keyword argument called
46             ``user_data`` will be passed to the callback function. It will be a ``dict`` you
47             can use to keep any data related to the user that sent the update. For each update of
48             the same user, it will be the same ``dict``. Default is ``False``.
49         pass_chat_data (optional[bool]): If set to ``True``, a keyword argument called
50             ``chat_data`` will be passed to the callback function. It will be a ``dict`` you
51             can use to keep any data related to the chat that the update was sent in.
52             For each update in the same chat, it will be the same ``dict``. Default is ``False``.
53         message_updates (Optional[bool]): Should "normal" message updates be handled? Default is
54             ``True``.
55         channel_post_updates (Optional[bool]): Should channel posts updates be handled? Default is
56             ``True``.
57 
58     """
59 
60     def __init__(self,
61                  filters,
62                  callback,
63                  allow_edited=False,
64                  pass_update_queue=False,
65                  pass_job_queue=False,
66                  pass_user_data=False,
67                  pass_chat_data=False,
68                  message_updates=True,
69                  channel_post_updates=True):
70         if not message_updates and not channel_post_updates:
71             raise ValueError('Both message_updates & channel_post_updates are False')
72 
73         super(MessageHandler, self).__init__(
74             callback,
75             pass_update_queue=pass_update_queue,
76             pass_job_queue=pass_job_queue,
77             pass_user_data=pass_user_data,
78             pass_chat_data=pass_chat_data)
79         self.filters = filters
80         self.allow_edited = allow_edited
81         self.message_updates = message_updates
82         self.channel_post_updates = channel_post_updates
83 
84         # We put this up here instead of with the rest of checking code
85         # in check_update since we don't wanna spam a ton
86         if isinstance(self.filters, list):
87             warnings.warn('Using a list of filters in MessageHandler is getting '
88                           'deprecated, please use bitwise operators (& and |) '
89                           'instead. More info: https://git.io/vPTbc.')
90 
91     def _is_allowed_message(self, update):
92         return (self.message_updates
93                 and (update.message or (update.edited_message and self.allow_edited)))
94 
95     def _is_allowed_channel_post(self, update):
96         return (self.channel_post_updates
97                 and (update.channel_post or (update.edited_channel_post and self.allow_edited)))
98 
99     def check_update(self, update):
100         if (isinstance(update, Update)
101                 and (self._is_allowed_message(update) or self._is_allowed_channel_post(update))):
102 
103             if not self.filters:
104                 res = True
105 
106             else:
107                 message = update.effective_message
108                 if isinstance(self.filters, list):
109                     res = any(func(message) for func in self.filters)
110                 else:
111                     res = self.filters(message)
112 
113         else:
114             res = False
115 
116         return res
117 
118     def handle_update(self, update, dispatcher):
119         optional_args = self.collect_optional_args(dispatcher, update)
120 
121         return self.callback(dispatcher.bot, update, **optional_args)
122
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/telegram/ext/messagehandler.py b/telegram/ext/messagehandler.py
--- a/telegram/ext/messagehandler.py
+++ b/telegram/ext/messagehandler.py
@@ -37,8 +37,6 @@
         callback (function): A function that takes ``bot, update`` as
             positional arguments. It will be called when the ``check_update``
             has determined that an update should be processed by this handler.
-        allow_edited (Optional[bool]): If the handler should also accept edited messages.
-            Default is ``False``
         pass_update_queue (optional[bool]): If the handler should be passed the
             update queue as a keyword argument called ``update_queue``. It can
             be used to insert updates. Default is ``False``
@@ -52,8 +50,12 @@
             For each update in the same chat, it will be the same ``dict``. Default is ``False``.
         message_updates (Optional[bool]): Should "normal" message updates be handled? Default is
             ``True``.
+        allow_edited (Optional[bool]): If the handler should also accept edited messages.
+            Default is ``False`` - Deprecated. use edited updates instead.
         channel_post_updates (Optional[bool]): Should channel posts updates be handled? Default is
             ``True``.
+        edited_updates (Optional[bool]): Should "edited" message updates be handled? Default is
+            ``False``.
 
     """
 
@@ -66,9 +68,14 @@
                  pass_user_data=False,
                  pass_chat_data=False,
                  message_updates=True,
-                 channel_post_updates=True):
-        if not message_updates and not channel_post_updates:
-            raise ValueError('Both message_updates & channel_post_updates are False')
+                 channel_post_updates=True,
+                 edited_updates=False):
+        if not message_updates and not channel_post_updates and not edited_updates:
+            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')
+            edited_updates = allow_edited
 
         super(MessageHandler, self).__init__(
             callback,
@@ -77,9 +84,9 @@
             pass_user_data=pass_user_data,
             pass_chat_data=pass_chat_data)
         self.filters = filters
-        self.allow_edited = allow_edited
         self.message_updates = message_updates
         self.channel_post_updates = channel_post_updates
+        self.edited_updates = edited_updates
 
         # We put this up here instead of with the rest of checking code
         # in check_update since we don't wanna spam a ton
@@ -88,17 +95,13 @@
                           'deprecated, please use bitwise operators (& and |) '
                           'instead. More info: https://git.io/vPTbc.')
 
-    def _is_allowed_message(self, update):
-        return (self.message_updates
-                and (update.message or (update.edited_message and self.allow_edited)))
-
-    def _is_allowed_channel_post(self, update):
-        return (self.channel_post_updates
-                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.edited_updates and update.edited_message),
+                    (self.channel_post_updates and update.channel_post)])
 
     def check_update(self, update):
-        if (isinstance(update, Update)
-                and (self._is_allowed_message(update) or self._is_allowed_channel_post(update))):
+        if isinstance(update, Update) and self._is_allowed_update(update):
 
             if not self.filters:
                 res = True

{"golden_diff": "diff --git a/telegram/ext/messagehandler.py b/telegram/ext/messagehandler.py\n--- a/telegram/ext/messagehandler.py\n+++ b/telegram/ext/messagehandler.py\n@@ -37,8 +37,6 @@\n         callback (function): A function that takes ``bot, update`` as\n             positional arguments. It will be called when the ``check_update``\n             has determined that an update should be processed by this handler.\n-        allow_edited (Optional[bool]): If the handler should also accept edited messages.\n-            Default is ``False``\n         pass_update_queue (optional[bool]): If the handler should be passed the\n             update queue as a keyword argument called ``update_queue``. It can\n             be used to insert updates. Default is ``False``\n@@ -52,8 +50,12 @@\n             For each update in the same chat, it will be the same ``dict``. Default is ``False``.\n         message_updates (Optional[bool]): Should \"normal\" message updates be handled? Default is\n             ``True``.\n+        allow_edited (Optional[bool]): If the handler should also accept edited messages.\n+            Default is ``False`` - Deprecated. use edited updates instead.\n         channel_post_updates (Optional[bool]): Should channel posts updates be handled? Default is\n             ``True``.\n+        edited_updates (Optional[bool]): Should \"edited\" message updates be handled? Default is\n+            ``False``.\n \n     \"\"\"\n \n@@ -66,9 +68,14 @@\n                  pass_user_data=False,\n                  pass_chat_data=False,\n                  message_updates=True,\n-                 channel_post_updates=True):\n-        if not message_updates and not channel_post_updates:\n-            raise ValueError('Both message_updates & channel_post_updates are False')\n+                 channel_post_updates=True,\n+                 edited_updates=False):\n+        if not message_updates and not channel_post_updates and not edited_updates:\n+            raise ValueError(\n+                'message_updates, channel_post_updates and edited_updates are all False')\n+        if allow_edited:\n+            warnings.warn('allow_edited is getting deprecated, please use edited_updates instead')\n+            edited_updates = allow_edited\n \n         super(MessageHandler, self).__init__(\n             callback,\n@@ -77,9 +84,9 @@\n             pass_user_data=pass_user_data,\n             pass_chat_data=pass_chat_data)\n         self.filters = filters\n-        self.allow_edited = allow_edited\n         self.message_updates = message_updates\n         self.channel_post_updates = channel_post_updates\n+        self.edited_updates = edited_updates\n \n         # We put this up here instead of with the rest of checking code\n         # in check_update since we don't wanna spam a ton\n@@ -88,17 +95,13 @@\n                           'deprecated, please use bitwise operators (& and |) '\n                           'instead. More info: https://git.io/vPTbc.')\n \n-    def _is_allowed_message(self, update):\n-        return (self.message_updates\n-                and (update.message or (update.edited_message and self.allow_edited)))\n-\n-    def _is_allowed_channel_post(self, update):\n-        return (self.channel_post_updates\n-                and (update.channel_post or (update.edited_channel_post and self.allow_edited)))\n+    def _is_allowed_update(self, update):\n+        return any([(self.message_updates and update.message),\n+                    (self.edited_updates and update.edited_message),\n+                    (self.channel_post_updates and update.channel_post)])\n \n     def check_update(self, update):\n-        if (isinstance(update, Update)\n-                and (self._is_allowed_message(update) or self._is_allowed_channel_post(update))):\n+        if isinstance(update, Update) and self._is_allowed_update(update):\n \n             if not self.filters:\n                 res = True\n", "issue": "add ability to handle only edited messages updates\nActually if you want to develop a bot where when a user edits his message it replies \"you edited this message\" or a bot that in groups kicks users that edit their messages (let's imagine a strange rule), there is not a handler to handle only edited messages.\r\n\r\nmessagehandler just handles any messages and not only those edited. So a handler or a filter to handle only edited messages is needed. Thanks\r\n\r\n\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2017\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\"\"\" This module contains the MessageHandler class \"\"\"\nimport warnings\n\nfrom .handler import Handler\nfrom telegram import Update\n\n\nclass MessageHandler(Handler):\n    \"\"\"\n    Handler class to handle telegram messages. Messages are Telegram Updates\n    that do not contain a command. They might contain text, media or status\n    updates.\n\n    Args:\n        filters (telegram.ext.BaseFilter): A filter inheriting from\n            :class:`telegram.ext.filters.BaseFilter`. Standard filters can be found in\n            :class:`telegram.ext.filters.Filters`. Filters can be combined using bitwise\n            operators (& for and, | for or).\n        callback (function): A function that takes ``bot, update`` as\n            positional arguments. It will be called when the ``check_update``\n            has determined that an update should be processed by this handler.\n        allow_edited (Optional[bool]): If the handler should also accept edited messages.\n            Default is ``False``\n        pass_update_queue (optional[bool]): If the handler should be passed the\n            update queue as a keyword argument called ``update_queue``. It can\n            be used to insert updates. Default is ``False``\n        pass_user_data (optional[bool]): If set to ``True``, a keyword argument called\n            ``user_data`` will be passed to the callback function. It will be a ``dict`` you\n            can use to keep any data related to the user that sent the update. For each update of\n            the same user, it will be the same ``dict``. Default is ``False``.\n        pass_chat_data (optional[bool]): If set to ``True``, a keyword argument called\n            ``chat_data`` will be passed to the callback function. It will be a ``dict`` you\n            can use to keep any data related to the chat that the update was sent in.\n            For each update in the same chat, it will be the same ``dict``. Default is ``False``.\n        message_updates (Optional[bool]): Should \"normal\" message updates be handled? Default is\n            ``True``.\n        channel_post_updates (Optional[bool]): Should channel posts updates be handled? Default is\n            ``True``.\n\n    \"\"\"\n\n    def __init__(self,\n                 filters,\n                 callback,\n                 allow_edited=False,\n                 pass_update_queue=False,\n                 pass_job_queue=False,\n                 pass_user_data=False,\n                 pass_chat_data=False,\n                 message_updates=True,\n                 channel_post_updates=True):\n        if not message_updates and not channel_post_updates:\n            raise ValueError('Both message_updates & channel_post_updates are False')\n\n        super(MessageHandler, self).__init__(\n            callback,\n            pass_update_queue=pass_update_queue,\n            pass_job_queue=pass_job_queue,\n            pass_user_data=pass_user_data,\n            pass_chat_data=pass_chat_data)\n        self.filters = filters\n        self.allow_edited = allow_edited\n        self.message_updates = message_updates\n        self.channel_post_updates = channel_post_updates\n\n        # We put this up here instead of with the rest of checking code\n        # in check_update since we don't wanna spam a ton\n        if isinstance(self.filters, list):\n            warnings.warn('Using a list of filters in MessageHandler is getting '\n                          'deprecated, please use bitwise operators (& and |) '\n                          'instead. More info: https://git.io/vPTbc.')\n\n    def _is_allowed_message(self, update):\n        return (self.message_updates\n                and (update.message or (update.edited_message and self.allow_edited)))\n\n    def _is_allowed_channel_post(self, update):\n        return (self.channel_post_updates\n                and (update.channel_post or (update.edited_channel_post and self.allow_edited)))\n\n    def check_update(self, update):\n        if (isinstance(update, Update)\n                and (self._is_allowed_message(update) or self._is_allowed_channel_post(update))):\n\n            if not self.filters:\n                res = True\n\n            else:\n                message = update.effective_message\n                if isinstance(self.filters, list):\n                    res = any(func(message) for func in self.filters)\n                else:\n                    res = self.filters(message)\n\n        else:\n            res = False\n\n        return res\n\n    def handle_update(self, update, dispatcher):\n        optional_args = self.collect_optional_args(dispatcher, update)\n\n        return self.callback(dispatcher.bot, update, **optional_args)\n", "path": "telegram/ext/messagehandler.py"}], "after_files": [{"content": "#!/usr/bin/env python\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2017\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\"\"\" This module contains the MessageHandler class \"\"\"\nimport warnings\n\nfrom .handler import Handler\nfrom telegram import Update\n\n\nclass MessageHandler(Handler):\n    \"\"\"\n    Handler class to handle telegram messages. Messages are Telegram Updates\n    that do not contain a command. They might contain text, media or status\n    updates.\n\n    Args:\n        filters (telegram.ext.BaseFilter): A filter inheriting from\n            :class:`telegram.ext.filters.BaseFilter`. Standard filters can be found in\n            :class:`telegram.ext.filters.Filters`. Filters can be combined using bitwise\n            operators (& for and, | for or).\n        callback (function): A function that takes ``bot, update`` as\n            positional arguments. It will be called when the ``check_update``\n            has determined that an update should be processed by this handler.\n        pass_update_queue (optional[bool]): If the handler should be passed the\n            update queue as a keyword argument called ``update_queue``. It can\n            be used to insert updates. Default is ``False``\n        pass_user_data (optional[bool]): If set to ``True``, a keyword argument called\n            ``user_data`` will be passed to the callback function. It will be a ``dict`` you\n            can use to keep any data related to the user that sent the update. For each update of\n            the same user, it will be the same ``dict``. Default is ``False``.\n        pass_chat_data (optional[bool]): If set to ``True``, a keyword argument called\n            ``chat_data`` will be passed to the callback function. It will be a ``dict`` you\n            can use to keep any data related to the chat that the update was sent in.\n            For each update in the same chat, it will be the same ``dict``. Default is ``False``.\n        message_updates (Optional[bool]): Should \"normal\" message updates be handled? Default is\n            ``True``.\n        allow_edited (Optional[bool]): If the handler should also accept edited messages.\n            Default is ``False`` - Deprecated. use edited updates instead.\n        channel_post_updates (Optional[bool]): Should channel posts updates be handled? Default is\n            ``True``.\n        edited_updates (Optional[bool]): Should \"edited\" message updates be handled? Default is\n            ``False``.\n\n    \"\"\"\n\n    def __init__(self,\n                 filters,\n                 callback,\n                 allow_edited=False,\n                 pass_update_queue=False,\n                 pass_job_queue=False,\n                 pass_user_data=False,\n                 pass_chat_data=False,\n                 message_updates=True,\n                 channel_post_updates=True,\n                 edited_updates=False):\n        if not message_updates and not channel_post_updates and not edited_updates:\n            raise ValueError(\n                'message_updates, channel_post_updates and edited_updates are all False')\n        if allow_edited:\n            warnings.warn('allow_edited is getting deprecated, please use edited_updates instead')\n            edited_updates = allow_edited\n\n        super(MessageHandler, self).__init__(\n            callback,\n            pass_update_queue=pass_update_queue,\n            pass_job_queue=pass_job_queue,\n            pass_user_data=pass_user_data,\n            pass_chat_data=pass_chat_data)\n        self.filters = filters\n        self.message_updates = message_updates\n        self.channel_post_updates = channel_post_updates\n        self.edited_updates = edited_updates\n\n        # We put this up here instead of with the rest of checking code\n        # in check_update since we don't wanna spam a ton\n        if isinstance(self.filters, list):\n            warnings.warn('Using a list of filters in MessageHandler is getting '\n                          'deprecated, please use bitwise operators (& and |) '\n                          'instead. More info: https://git.io/vPTbc.')\n\n    def _is_allowed_update(self, update):\n        return any([(self.message_updates and update.message),\n                    (self.edited_updates and update.edited_message),\n                    (self.channel_post_updates and update.channel_post)])\n\n    def check_update(self, update):\n        if isinstance(update, Update) and self._is_allowed_update(update):\n\n            if not self.filters:\n                res = True\n\n            else:\n                message = update.effective_message\n                if isinstance(self.filters, list):\n                    res = any(func(message) for func in self.filters)\n                else:\n                    res = self.filters(message)\n\n        else:\n            res = False\n\n        return res\n\n    def handle_update(self, update, dispatcher):\n        optional_args = self.collect_optional_args(dispatcher, update)\n\n        return self.callback(dispatcher.bot, update, **optional_args)\n", "path": "telegram/ext/messagehandler.py"}]}