# Buggy code
def _send_telegram_msg(self, title, msg, user_id=None, api_key=None):
    """
    Sends a Telegram notification

    :param title: The title of the notification to send
    :param msg: The message string to send
    :param id: The Telegram user/group id to send the message to
    :param api_key: Your Telegram bot API token

    :returns: True if the message succeeded, False otherwise
    """
    user_id = app.TELEGRAM_ID if user_id is None else user_id
    api_key = app.TELEGRAM_APIKEY if api_key is None else api_key

    log.debug("Telegram in use with API KEY: {0}", api_key)

    message = "{0} : {1}".format(title, msg).encode("utf-8")
    payload = {"chat_id": user_id, "text": message}
    telegram_api = "https://api.telegram.org/bot{api_key}/sendMessage"

    success = False
    try:
        r = requests.post(telegram_api.format(api_key=api_key), data=payload)
        r.raise_for_status()
        message = "Telegram message sent successfully."
        success = True
    except RequestException as error:
        message = "Unknown IO error: %s" % error
        if hasattr(error, "response"):
            error_message = {
                400: "Missing parameter(s). Double check your settings or if the channel/user exists.",
                401: "Authentication failed.",
                420: "Too many messages.",
                500: "Server error. Please retry in a few moments.",
            }
            if error.response.status_code in error_message:
                message = error_message.get(error.response.status_code)
            else:
                message = http_status_code.get(error.response.status_code, message)
    except Exception as e:
        message = "Error while sending Telegram message: %s " % e
    finally:
        log.info(message)
    return success, message


# Traceback (OSError)
2019-01-22 00:24:41 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Search string: Fuck Thats Delicious S03E02
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] GET URL: https://www.scenetime.com/browse.php?cata=yes&c2=1&c43=1&c9=1&c63=1&c77=1&c79=1&c100=1&c83=1&c8=1&c18=1&c19=1&search=Fuck+Thats+Delicious+S03E02 [Status: 200]
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] User-Agent: Medusa/0.2.14 (Linux; 4.9.35-v7+; 61e500e8-1b10-11e9-ab36-b827eb6b4d4c)
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Discarding torrent because it doesn't meet the minimum seeders: Fuck Thats Delicious S03E02 720p HEVC x265-MeGusta. Seeders: 0
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Discarding torrent because it doesn't meet the minimum seeders: Fuck Thats Delicious S03E02 XviD-AFG. Seeders: 0
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Discarding torrent because it doesn't meet the minimum seeders: Fuck Thats Delicious S03E02 480p x264-mSD. Seeders: 0
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Discarding torrent because it doesn't meet the minimum seeders: Fuck Thats Delicious S03E02 AAC MP4-Mobile. Seeders: 0
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Discarding torrent because it doesn't meet the minimum seeders: Fuck Thats Delicious S03E02 HDTV x264-YesTV. Seeders: 0
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Discarding torrent because it doesn't meet the minimum seeders: Fuck Thats Delicious S03E02 720p HDTV x264-YesTV. Seeders: 0
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Discarding torrent because it doesn't meet the minimum seeders: Fuck Thats Delicious S03E02 New Jersey Food Drive 720p HEVC x265-MeGusta. Seeders: 0
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Discarding torrent because it doesn't meet the minimum seeders: Fuck Thats Delicious S03E02 New Jersey Food Drive AAC MP4-Mobile. Seeders: 0
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Discarding torrent because it doesn't meet the minimum seeders: Fuck Thats Delicious S03E02 New Jersey Food Drive XviD-AFG. Seeders: 0
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Discarding torrent because it doesn't meet the minimum seeders: Fuck Thats Delicious S03E02 New Jersey Food Drive 1080p WEB x264-CAFFEiNE. Seeders: 0
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Discarding torrent because it doesn't meet the minimum seeders: Fuck Thats Delicious S03E02 New Jersey Food Drive WEB x264-CAFFEiNE. Seeders: 0
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Found result: Fuck Thats Delicious S03E02 New Jersey Food Drive 720p WEB x264-CAFFEiNE with 1 seeders and 0 leechers
2019-01-22 00:24:43 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Search string: F*ck, That's Delicious S03E02
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] GET URL: https://www.scenetime.com/browse.php?cata=yes&c2=1&c43=1&c9=1&c63=1&c77=1&c79=1&c100=1&c83=1&c8=1&c18=1&c19=1&search=F%2Ack%2C+That%27s+Delicious+S03E02 [Status: 200]
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] User-Agent: Medusa/0.2.14 (Linux; 4.9.35-v7+; 61e500e8-1b10-11e9-ab36-b827eb6b4d4c)
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Data returned from provider does not contain any torrents
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Found 1 unique items
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Found qualities: [64]
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Using cached parse result for Fuck.Thats.Delicious.S03E02.New.Jersey.Food.Drive.720p.WEB.x264-CAFFEiNE
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Adding item from search to cache: 'Fuck.Thats.Delicious.S03E02.New.Jersey.Food.Drive.720p.WEB.x264-CAFFEiNE'
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Updating item: Fuck.Thats.Delicious.S03E02.New.Jersey.Food.Drive.720p.WEB.x264-CAFFEiNE to cache: scenetime
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Found result Fuck.Thats.Delicious.S03E02.New.Jersey.Food.Drive.720p.WEB.x264-CAFFEiNE at https://www.scenetime.com/download.php//1853848/Fuck.Thats.Delicious.S03E02.New.Jersey.Food.Drive.720p.WEB.x264-CAFFEiNE.torrent
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Found single episode result Fuck.Thats.Delicious.S03E02.New.Jersey.Food.Drive.720p.WEB.x264-CAFFEiNE at https://www.scenetime.com/download.php//1853848/Fuck.Thats.Delicious.S03E02.New.Jersey.Food.Drive.720p.WEB.x264-CAFFEiNE.torrent
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Transaction with 1 queries executed
2019-01-22 00:24:45 INFO     SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Removing cache entries older than 15 days from scenetime
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Adding to cache item found in manual search: Fuck.Thats.Delicious.S03E02.New.Jersey.Food.Drive.720p.WEB.x264-CAFFEiNE
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Using cached parse result for Fuck.Thats.Delicious.S03E02.New.Jersey.Food.Drive.720p.WEB.x264-CAFFEiNE
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Updating item: Fuck.Thats.Delicious.S03E02.New.Jersey.Food.Drive.720p.WEB.x264-CAFFEiNE to cache: scenetime
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Mass updating cache table with manual results for provider: SceneTime
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [SceneTime] :: [6bd26dd] Transaction with 1 queries executed
2019-01-22 00:24:45 INFO     SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Performing episode search for F*ck, That's Delicious
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Could not find any candidates in cache, searching provider.
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Search mode: Episode
2019-01-22 00:24:45 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Search string: Fuck Thats Delicious S03E02
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] GET URL: https://hd-torrents.org/torrents.php?search=Fuck+Thats+Delicious+S03E02&active=1&options=0&category%5B0%5D=59&category%5B1%5D=60&category%5B2%5D=30&category%5B3%5D=38&category%5B4%5D=65 [Status: 200]
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] User-Agent: Medusa/0.2.14 (Linux; 4.9.35-v7+; 61e500e8-1b10-11e9-ab36-b827eb6b4d4c)
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Data returned from provider does not contain any torrents
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Search string: F*ck, That's Delicious S03E02
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] GET URL: https://hd-torrents.org/torrents.php?search=F%2Ack%2C+That%27s+Delicious+S03E02&active=1&options=0&category%5B0%5D=59&category%5B1%5D=60&category%5B2%5D=30&category%5B3%5D=38&category%5B4%5D=65 [Status: 200]
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] User-Agent: Medusa/0.2.14 (Linux; 4.9.35-v7+; 61e500e8-1b10-11e9-ab36-b827eb6b4d4c)
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Data returned from provider does not contain any torrents
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Found 0 unique items
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Found qualities: []
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Fallback season pack search initiated
2019-01-22 00:24:46 INFO     SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Performing season pack search for F*ck, That's Delicious
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Could not find any candidates in cache, searching provider.
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Found 0 unique items
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [HDTorrents] :: [6bd26dd] Found qualities: []
2019-01-22 00:24:46 INFO     SEARCHQUEUE-MANUAL-281403 :: [TorrentDay] :: [6bd26dd] Performing episode search for F*ck, That's Delicious
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [TorrentDay] :: [6bd26dd] Could not find any candidates in cache, searching provider.
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [TorrentDay] :: [6bd26dd] Search mode: Episode
2019-01-22 00:24:46 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [TorrentDay] :: [6bd26dd] Search string: Fuck Thats Delicious S03E02
2019-01-22 00:24:47 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [TorrentDay] :: [6bd26dd] GET URL: https://www.torrentday.com/t.json?q=Fuck%2BThats%2BDelicious%2BS03E02&2=1&26=1&7=1&24=1&34=1 [Status: 200]
2019-01-22 00:24:47 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [TorrentDay] :: [6bd26dd] User-Agent: Medusa/0.2.14 (Linux; 4.9.35-v7+; 61e500e8-1b10-11e9-ab36-b827eb6b4d4c)
2019-01-22 00:24:47 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [TorrentDay] :: [6bd26dd] Search string: F*ck, That's Delicious S03E02
2019-01-22 00:24:47 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [TorrentDay] :: [6bd26dd] GET URL: https://www.torrentday.com/t.json?q=F%2Ack%2C%2BThat%27s%2BDelicious%2BS03E02&2=1&26=1&7=1&24=1&34=1 [Status: 200]
2019-01-22 00:24:47 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [TorrentDay] :: [6bd26dd] User-Agent: Medusa/0.2.14 (Linux; 4.9.35-v7+; 61e500e8-1b10-11e9-ab36-b827eb6b4d4c)
2019-01-22 00:24:47 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [TorrentDay] :: [6bd26dd] Found 0 unique items
2019-01-22 00:24:47 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [TorrentDay] :: [6bd26dd] Found qualities: []
2019-01-22 00:24:47 INFO     SEARCHQUEUE-MANUAL-281403 :: [ALTHUB] :: [6bd26dd] Performing episode search for F*ck, That's Delicious
2019-01-22 00:24:47 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [ALTHUB] :: [6bd26dd] Could not find any candidates in cache, searching provider.
2019-01-22 00:24:47 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [ALTHUB] :: [6bd26dd] GET URL: **********api?t=caps&apikey=**********
2019-01-22 00:24:47 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [ALTHUB] :: [6bd26dd] User-Agent: Medusa/0.2.14 (Linux; 4.9.35-v7+; 61e500e8-1b10-11e9-ab36-b827eb6b4d4c)
2019-01-22 00:24:50 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [ALTHUB] :: [6bd26dd] Search mode: Episode
2019-01-22 00:24:50 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [ALTHUB] :: [6bd26dd] Search show using search string: indexer_id: {'tvdbid': 281403}
2019-01-22 00:24:50 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [ALTHUB] :: [6bd26dd] GET URL: **********api?t=tvsearch&limit=100&offset=0&cat=5000%2C5080%2C5020%2C5040%2C5050%2C5030%2C5060%2C5045&maxage=3331&apikey=**********&tvdbid=281403&season=3&ep=2 [Status: 200]
2019-01-22 00:24:50 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [ALTHUB] :: [6bd26dd] User-Agent: Medusa/0.2.14 (Linux; 4.9.35-v7+; 61e500e8-1b10-11e9-ab36-b827eb6b4d4c)
2019-01-22 00:24:50 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [ALTHUB] :: [6bd26dd] No results returned from provider. Check chosen Newznab search categories in provider settings and/or usenet retention
2019-01-22 00:24:50 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [ALTHUB] :: [6bd26dd] Search mode: Episode
2019-01-22 00:24:50 DEBUG    SEARCHQUEUE-MANUAL-281403 :: [ALTHUB] :: [6bd26dd] Search show using search string: Fuck Thats Delicious S03E02
2019-01-22 00:24:50 INFO     SNATCHQUEUE-SNATCH-270633 :: [6bd26dd] Unknown IO error: ('Connection aborted.', OSError(0, 'Error'))
2019-01-22 00:24:50 ERROR    SNATCHQUEUE-SNATCH-270633 :: [6bd26dd] Snatch failed! For result: True.Detective.S03E03.The.Big.Never.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv
Traceback (most recent call last):
  File "/home/pi/Medusa/ext/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/pi/Medusa/ext/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/home/pi/Medusa/ext/urllib3/connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "/home/pi/Medusa/ext/urllib3/connection.py", line 344, in connect
    ssl_context=context)
  File "/home/pi/Medusa/ext/urllib3/util/ssl_.py", line 344, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/usr/lib/python3.6/ssl.py", line 817, in __init__
    self.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
OSError: [Errno 0] Error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/pi/Medusa/ext/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/home/pi/Medusa/ext/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/pi/Medusa/ext/urllib3/util/retry.py", line 367, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/pi/Medusa/ext/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/Medusa/ext/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/pi/Medusa/ext/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/home/pi/Medusa/ext/urllib3/connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "/home/pi/Medusa/ext/urllib3/connection.py", line 344, in connect
    ssl_context=context)
  File "/home/pi/Medusa/ext/urllib3/util/ssl_.py", line 344, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/usr/lib/python3.6/ssl.py", line 817, in __init__
    self.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError(0, 'Error'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/pi/Medusa/medusa/notifiers/telegram.py", line 65, in _send_telegram_msg
    r = requests.post(telegram_api.format(api_key=api_key), data=payload)
  File "/home/pi/Medusa/ext/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/pi/Medusa/ext/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/pi/Medusa/ext/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/pi/Medusa/ext/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/home/pi/Medusa/ext/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError(0, 'Error'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/pi/Medusa/medusa/search/queue.py", line 503, in run
    self.success = snatch_episode(result)
  File "/home/pi/Medusa/medusa/search/core.py", line 222, in snatch_episode
    notifiers.notify_snatch(curEpObj, result)
  File "/home/pi/Medusa/medusa/notifiers/__init__.py", line 127, in notify_snatch
    n.notify_snatch(title, message)
  File "/home/pi/Medusa/medusa/notifiers/telegram.py", line 96, in notify_snatch
    self._notify_telegram(title, message)
  File "/home/pi/Medusa/medusa/notifiers/telegram.py", line 160, in _notify_telegram
    return self._send_telegram_msg(title, message, user_id, api_key)
  File "/home/pi/Medusa/medusa/notifiers/telegram.py", line 78, in _send_telegram_msg
    if error.response.status_code in error_message:
AttributeError: 'NoneType' object has no attribute 'status_code'

# Fixed code
def _send_telegram_msg(self, title, msg, user_id=None, api_key=None):
    """
    Sends a Telegram notification

    :param title: The title of the notification to send
    :param msg: The message string to send
    :param id: The Telegram user/group id to send the message to
    :param api_key: Your Telegram bot API token

    :returns: True if the message succeeded, False otherwise
    """
    user_id = app.TELEGRAM_ID if user_id is None else user_id
    api_key = app.TELEGRAM_APIKEY if api_key is None else api_key

    log.debug("Telegram in use with API KEY: {0}", api_key)

    message = "{0} : {1}".format(title, msg).encode("utf-8")
    payload = {"chat_id": user_id, "text": message}
    telegram_api = "https://api.telegram.org/bot{api_key}/sendMessage"

    success = False
    try:
        r = requests.post(telegram_api.format(api_key=api_key), data=payload)
        r.raise_for_status()
        message = "Telegram message sent successfully."
        success = True
    except RequestException as error:
        message = "Unknown IO error: %s" % error
        if hasattr(error, "response") and error.response is not None:
            error_message = {
                400: "Missing parameter(s). Double check your settings or if the channel/user exists.",
                401: "Authentication failed.",
                420: "Too many messages.",
                500: "Server error. Please retry in a few moments.",
            }
            if error.response.status_code in error_message:
                message = error_message.get(error.response.status_code)
            else:
                message = http_status_code.get(error.response.status_code, message)
    except Exception as e:
        message = "Error while sending Telegram message: %s " % e
    finally:
        log.info(message)
    return success, message