def list_alerts(self, command, typeof, name):
        params = {
            'filter': {'fixed': False}
        }
        valid = ['service', 'device']
        if typeof and valid in typeof:
            params['filter']['config.subjectType'] = typeof
        elif typeof == 'group':
            params['filter']['subjectGroup'] = name
        elif typeof in ['all', '']:
            pass  # don't need to do anything
        else:
            text = 'Instead of `{}` you should have used `group`, `service`, `device` or `all`'.format(typeof), ''
            return text

        services = self.service.list()
        devices = self.device.list()

        if name and typeof != 'group':
            _id = name if not name else self.find_id(name, services, devices)
            params['filter']['config.subjectId'] = _id

        results = self.alert.triggered(params=params)
        alerts = sorted(results, key=lambda alert: alert['config']['lastTriggeredAt']['sec'], reverse=True)
        if not (typeof or name):
            # When making a standard `alerts list` we want to give a limited amount of alerts.
            stripped_alerts = alerts[:5]
        else:
            # we want to keep the entire list here
            stripped_alerts = alerts
        open_alerts = []

        for alert in stripped_alerts:
            field = alert['config']['fullName'].split(' > ')
            comparison = alert['config'].get('fullComparison', '')
            value = '{}{}'.format(alert['config'].get('value', ''), alert['config'].get('units', ''))
            group = alert['config'].get('group', 'Ungrouped')
            triggered_time = time.localtime(alert['config']['lastTriggeredAt']['sec'])

            _id = alert['config']['subjectId']
            if self._is_mongoId(_id):
                name = self.find_name(_id, services, devices)
                name = '{}: {}'.format(alert['config']['subjectType'].title(), name)
            else:
                name = 'Group: {}'.format(_id)

            attachment = {
                'title': '{}'.format(name),
                'text': '{} {} {}'.format(
                    field[1],
                    comparison,
                    value
                ),
                'color': COLOR,
                'fields': [
                    {
                        'title': 'Last triggered',
                        'value': time.strftime('%Y-%m-%d, %H:%M:%S', triggered_time)
                    },
                    # waiting on backend bugfix sd-2190
                    # {
                    #     'title': 'Group',
                    #     'value': group,
                    #     'short': True
                    # }
                ]
            }
            open_alerts.append(attachment)
        if open_alerts:
            if len(alerts) > len(stripped_alerts):
                message = ('You have {} open alerts but I\'m only showing the last {},'.format(len(alerts), len(stripped_alerts)) +
                           ' do `list open alerts all` to see all of them')
            else:
                message = 'Chop chop, you\'d better sort out these open alerts soon'
            return open_alerts, message
        else:
            return 'I could not find any open alerts for you.', ''
dataset/ETHPy150Open serverdensity/sdbot/limbo/plugins/alerts.py/Wrapper.list_alerts/swapped operands of `in`