from typing import Tuple
from typing import Dict


def format_message(
        url: str, msg_attrs: Tuple[str, str], handle: str = ''
) -> Dict:
    """Return formatted message as Slack's BlockKit section.

    :param url: URL of news item.
    :param msg_attrs: tuple of title and category.
    :param handle: Handle of given feed.
    """
    if handle:
        if len(msg_attrs) > 1 and msg_attrs[1]:
            tag = '[{:s}-{:s}] '.format(handle, msg_attrs[1])
        else:
            tag = '[{:s}] '.format(handle)

    else:
        tag = ''

    return {
        'type': 'section',
        'text': {
            'type': 'mrkdwn',
            'text': '{}<{}|{}>'.format(tag, url, msg_attrs[0])
        }
    }