Exemplo n.º 1
0
    def get_channels(self, silent=False):
        response = self.api_call(u'conversations.list',
                                 exclude_archived=True,
                                 types='public_channel,private_channel')

        if not response['ok']:
            s = u'Maybe a required scope is missing?\nError: "{}"'.format(
                response[u'error'])
            if 'needed' in response:
                s += '\nScope needed: "{}"'.format(response['needed'])
            log.error(s)
            if not silent:
                common_ui.ErrorBox(u'Slack Token Error.', s).open()
            raise ValueError(s)

        channels = []
        for channel in response['channels']:
            if channel['is_archived']:
                continue
            if u'is_channel' in channel:
                if channel['is_channel']:
                    channels.append(channel)
            if u'is_group' in channel:
                if channel['is_group']:
                    channels.append(channel)
        return channels
Exemplo n.º 2
0
        def _get_profiles(response):
            if not response['ok']:
                s = u'Maybe a required scope is missing?\nError: "{}"'.format(
                    response[u'error'])
                if 'needed' in response:
                    s += '\nScope needed: "{}"'.format(response['needed'])
                log.error(s)
                if not silent:
                    common_ui.ErrorBox(u'Slack Token Error.', s).open()
                raise ValueError(s)

            _profiles = []
            for member in response['members']:
                if member[u'deleted']:
                    continue
                if member[u'is_app_user']:
                    continue
                if member[u'is_bot']:
                    continue
                _profiles.append(member)
            return _profiles