Repository: python-telegram-bot/python-telegram-bot
Pull request: fix-750
fixes #750

Problem statement:
RegexHandler error with stickers, voices, images...
RegexHandler does not check if update.effective_message.text exists.

### Steps to reproduce
1. Add a RegexHandler
2. Run the bot
3. Send a sticker

### Expected behaviour
The handler should not capture the sticker

### Actual behaviour
The handler capture the sticker and gives an error

### Configuration
Does not matter


**Version of Python, python-telegram-bot & dependencies:**

``python-telegram-bot 7.0.0``

### Logs
2017-07-26 14:02:47,301 - telegram.ext.dispatcher - ERROR - An uncaught error was raised while processing the update
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/telegram/ext/dispatcher.py", line 269, in process_update
    if handler.check_update(update):
  File "/usr/local/lib/python3.5/dist-packages/telegram/ext/regexhandler.py", line 150, in check_update
    match = re.match(self.pattern, update.effective_message.text)
  File "/usr/lib/python3.5/re.py", line 163, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object

Hints from issue discussion:

Commit message: fix-750

Patch to review:
diff --git a/telegram/ext/regexhandler.py b/telegram/ext/regexhandler.py
index 40df9de7a0a..3a76628c27e 100644
--- a/telegram/ext/regexhandler.py
+++ b/telegram/ext/regexhandler.py
@@ -146,7 +146,7 @@ def check_update(self, update):
         if any([(self.message_updates and update.message),
                 (self.edited_updates and update.edited_message),
                 (self.channel_post_updates and update.channel_post)]) and (
-                isinstance(update, Update)):
+                isinstance(update, Update)) and update.effective_message.text:
             match = re.match(self.pattern, update.effective_message.text)
             return bool(match)
         return False


Code review comments:
diff_hunk: @@ -146,7 +146,7 @@ def check_update(self, update):
         if any([(self.message_updates and update.message),
                 (self.edited_updates and update.edited_message),
                 (self.channel_post_updates and update.channel_post)]) and (
-                isinstance(update, Update)):
+                isinstance(update, Update)) and update.effective_message.text:
path: telegram/ext/regexhandler.py
text: @user1:
shouldn't we check that `update.effective_message` is not None?