import json
import html


def render_event_message(event_id, event_text, participants):
    """Render event message text."""
    text = '\U0001F37A <b>{}</b>\n<i>(id: {})</i>\n\n'.format(event_text,
                                                              event_id)
    if participants:
        users = []
        for participant in participants:
            user = json.loads(participant)
            if 'username' in user:
                name = '@' + user['username']
            else:
                name = user['first_name']
                if 'last_name' in user:
                    name += ' ' + user['last_name']
            users.append(html.escape(name))
        text += 'Идут ({}):\n{}\n'.format(len(users), ', '.join(users))
    else:
        text += 'Пока никто не идет.\n'

    return text