Repository: opsdroid/opsdroid

Issue:
Telegram connector needs update for event message
# Description
The telegram connector uses message.target['id'] instead of message.target.  This leads to problems when trying to use default_target per normal configuration and usage of the event flow logic.

## Steps to Reproduce
Setup telegram as the default connector... call the telegram connector.send with a target...  
```
await self.opsdroid.send(Message(text='hello', target='<useridhere>') 
```
The default_target is also always None.
```
await self.opsdroid.send(Message(text='hello')  
```
You can hack around it with..
```
sillytarget = { 'id': <useridhere> }
await self.opsdroid.send(Message(text='hello', target=sillytarget) 
```
## Expected Functionality
message.target should work like the other core connectors

## Experienced Functionality
Errors out.
```
opsdroid    | ERROR opsdroid.connector.telegram.send_message(): Unable to respond.   
```
## Versions

- opsdroid: latest/stable
- python 3.7.6
- docker image: opsdroid/opsdroid:latest

## Configuration File
```yaml
connectors:
## Telegram (core)
  telegram:
    token: "......"
   # optional
    update-interval: 0.5  # Interval between checking for messages
    whitelisted-users:  # List of users who can speak to the bot, if not set anyone can speak
      - ......
```
## Additional Details
None

<!-- 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
@@ -34,9 +34,9 @@ def __init__(self, config, opsdroid=None):
         self.name = "telegram"
         self.opsdroid = opsdroid
         self.latest_update = None
-        self.default_target = None
         self.listening = True
         self.default_user = config.get("default-user", None)
+        self.default_target = self.default_user
         self.whitelisted_users = config.get("whitelisted-users", None)
         self.update_interval = config.get("update-interval", 1)
         self.session = None
@@ -167,9 +167,13 @@ async def _parse_message(self, response):
         """
         for result in response["result"]:
             _LOGGER.debug(result)
+
             if result.get("edited_message", None):
                 result["message"] = result.pop("edited_message")
-            if "channel" in result["message"]["chat"]["type"]:
+            if result.get("channel_post", None) or result.get(
+                "edited_channel_post", None
+            ):
+                self.latest_update = result["update_id"] + 1
                 _LOGGER.debug(
                     _("Channel message parsing not supported " "- Ignoring message.")
                 )
@@ -179,7 +183,7 @@ async def _parse_message(self, response):
                     text=result["message"]["text"],
                     user=user,
                     user_id=user_id,
-                    target=result["message"]["chat"],
+                    target=result["message"]["chat"]["id"],
                     connector=self,
                 )
 
@@ -277,10 +281,12 @@ async def send_message(self, message):
             message (object): An instance of Message.
 
         """
-        _LOGGER.debug(_("Responding with: %s."), message.text)
+        _LOGGER.debug(
+            _("Responding with: '%s' at target: '%s'"), message.text, message.target
+        )
 
         data = dict()
-        data["chat_id"] = message.target["id"]
+        data["chat_id"] = message.target
         data["text"] = message.text
         resp = await self.session.post(self.build_url("sendMessage"), data=data)
         if resp.status == 200:


Test patch: