Repository: opsdroid/opsdroid

Issue:
Telegram connector stops working after a reply with just a GIF
<!-- Before you post an issue or if you are unsure about something join our matrix channel https://app.element.io/#/room/#opsdroid-general:matrix.org and ask away! We are more than happy to help you. -->
# Description
Bot stops working when a certain event occurs in the chat. It tries to handle a message but fails and does not react to subsequent messages.

## Steps to Reproduce

EDIT: A reply with just a gif is sufficient to trigger this. Send a GIF via `@gif something` as a reply to a message from the bot.

Not perfectly sure, but the error below points me to:
https://github.com/opsdroid/opsdroid/blob/33241f2d74940e061fada8eee8d8238230593295/opsdroid/connector/telegram/__init__.py#L308
```
        if message.get("reply_to_message"):
            event = Reply(
                text=emoji.demojize(message["text"]),
                user=user,
                user_id=user_id,
                event_id=message["message_id"],
                linked_event=message["reply_to_message"]["message_id"],
                target=message["chat"]["id"],
                connector=self,
                raw_event=message,
            )
```
So the best way of trying to reproduce it would be to sent a reply that does not contain a text (maybe just a sticker or emoji?)

## Expected Functionality
If there is a message that can not be handled the bot should skip it (and log the error) and continue.

## Experienced Functionality
The Bot logs an error and does not handle subsequent messages.

```
[05/05/22 05:42:19] ERROR    Error handling request          web_protocol.py:405
                             ╭─ Traceback (most recent cal─╮
                             │                             │
                             │ /usr/local/lib/python3.9/si │
                             │ te-packages/aiohttp/web_pro │
                             │ tocol.py:435 in             │
                             │ _handle_request             │
                             │                             │
                             │   432 │   │   try:          │
                             │   433 │   │   │   try:      │
                             │   434 │   │   │   │   self. │
                             │ ❱ 435 │   │   │   │   resp  │
                             │   436 │   │   │   finally:  │
                             │   437 │   │   │   │   self. │
                             │   438 │   │   except HTTPEx │
                             │ /usr/local/lib/python3.9/si │
                             │ te-packages/aiohttp/web_app │
                             │ .py:504 in _handle          │
                             │                             │
                             │   501 │   │   │   │   │   │ │
                             │   502 │   │   │   │   │   │ │
                             │   503 │   │   │             │
                             │ ❱ 504 │   │   │   resp = aw │
                             │   505 │   │                 │
                             │   506 │   │   return resp   │
                             │   507                       │
                             │                             │
                             │ /usr/local/lib/python3.9/si │
                             │ te-packages/opsdroid/connec │
                             │ tor/telegram/__init__.py:22 │
                             │ 8 in                        │
                             │ telegram_webhook_handler    │
                             │                             │
                             │   225 │   │   │   )         │
                             │   226 │   │                 │
                             │   227 │   │   if payload.ge │
                             │ ❱ 228 │   │   │   event = a │
                             │   229 │   │   │   │   paylo │
                             │   230 │   │   │   )         │
                             │   231                       │
                             │                             │
                             │ /usr/local/lib/python3.9/si │
                             │ te-packages/opsdroid/connec │
                             │ tor/telegram/__init__.py:30 │
                             │ 8 in handle_messages        │
                             │                             │
                             │   305 │   │                 │
                             │   306 │   │   if message.ge │
                             │   307 │   │   │   event = R │
                             │ ❱ 308 │   │   │   │   text= │
                             │   309 │   │   │   │   user= │
                             │   310 │   │   │   │   user_ │
                             │   311 │   │   │   │   event │
                             ╰─────────────────────────────╯
                             KeyError: 'text'
```

## Versions
- OpsDroid 0.26.0
- OpsDroid helm chart: opsdroid-0.1.6


<!-- Love opsdroid? Please consider supporting our collective:
 +👉  https://opencollective.com/opsdroid/donate -->



Discussion:

Resolving patch:
diff --git a/opsdroid/connector/telegram/__init__.py b/opsdroid/connector/telegram/__init__.py
--- a/opsdroid/connector/telegram/__init__.py
+++ b/opsdroid/connector/telegram/__init__.py
@@ -305,7 +305,7 @@ async def handle_messages(self, message, user, user_id, update_id):
 
         if message.get("reply_to_message"):
             event = Reply(
-                text=emoji.demojize(message["text"]),
+                text=emoji.demojize(message.get("text", "")),
                 user=user,
                 user_id=user_id,
                 event_id=message["message_id"],
@@ -317,7 +317,7 @@ async def handle_messages(self, message, user, user_id, update_id):
 
         if message.get("text"):
             event = Message(
-                text=emoji.demojize(message["text"]),
+                text=emoji.demojize(message.get("text", "")),
                 user=user,
                 user_id=user_id,
                 target=message["chat"]["id"],


Test patch: