Ejemplo n.º 1
0
    def build_slack_attachment(stats):
        """
        Builds the JSON attachment for the Slack message
        """
        message = {}
        name = stats['name']
        message['author_name'] = '%s (Player Stats)' % name
        message['color'] = 'good'
        message['author_link'] = get_player_link(name)
        message['author_icon'] = get_avatar_link(name)

        text = 'Rank: `%s` Rating: `%s`\nKills: `%s` Deaths: `%s` KD: `%s`\nWools: `%s` Cores: `%s` Monuments: `%s`' % (
            stats['rank'],
            stats['rating'], stats['kills'],
            stats['deaths'], stats['kd_ratio'], stats['wools'], stats['cores'], stats['monuments'])
        message['text'] = text
        message['mrkdwn_in'] = ['text']

        return message
Ejemplo n.º 2
0
    def build_slack_attachment(username, uuid, link, data):

        attach = {
            'author_name': '%s (Username History) (%s)' % (username, uuid),
            'author_link': link,
            'author_icon': get_avatar_link(username),
            'mrkdwn_in': ['text'],
            'text': ''
        }

        # Go backward in time
        for change in data[::-1]:
            attach['text'] += '`%s` - ' % change['name']
            if 'changedToAt' not in change:
                attach['text'] += '_(original)_'
            else:
                attach['text'] += timestamp_to_date(long(change['changedToAt']))
            attach['text'] += '\n'

        return attach