Send a message to a Telegram chat.

    :param chat_id:     The chat id.
    :param message:     The message to send to the telegram chat.
    :param token:       The Telegram API token.
    :return:            Boolean if message was sent successfully.

def _post_message(message, chat_id, token):
    '''
    Send a message to a Telegram chat.

    :param chat_id:     The chat id.
    :param message:     The message to send to the telegram chat.
    :param token:       The Telegram API token.
    :return:            Boolean if message was sent successfully.
    '''
    url = 'https://api.telegram.org/bot{0}/sendMessage'.format(token)

    parameters = dict()
    if chat_id:
        parameters['chat_id'] = chat_id
    if message:
        parameters['text'] = message

    try:
        response = requests.post(
            url,
            data=parameters
        )
        result = response.json()

        log.debug('Raw response of the telegram request is %s', response)

    except Exception:
        log.exception(
            'Sending telegram api request failed'
        )
        return False

    # Check if the Telegram Bot API returned successfully.
    if not result.get('ok', False):
        log.debug(
            'Sending telegram api request failed due to error %s (%s)',
            result.get('error_code'), result.get('description')
        )
        return False

    return True