How to use the twitchio.errors.ClientError function in twitchio

To help you get started, we’ve selected a few twitchio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TwitchIO / TwitchIO / twitchio / commands / bot.py View on Github external
async def _prefix_setter(self, item):
        if inspect.iscoroutinefunction(item):
            item = await item()
        elif callable(item):
            item = item()

        if isinstance(item, (list, tuple)):
            self.prefixes = item
        elif isinstance(item, str):
            self.prefixes = [item]
        else:
            raise ClientError('Invalid prefix provided. A list, tuple, str or callable returning either should be used.')
github TwitchIO / TwitchIO / twitchio / commands / bot.py View on Github external
async def _get_prefixes(self, message):
        prefix = ret = self.prefixes
        if callable(prefix):
            ret = prefix(self, message.content)
            if inspect.isawaitable(ret):
                ret = await ret

        if isinstance(ret, (list, tuple)):
            ret = [p for p in ret if p]

        if isinstance(ret, str):
            ret = [ret]

        if not ret:
            raise ClientError('Invalid prefix provided.')

        return ret
github TwitchIO / TwitchIO / twitchio / ext / commands / bot.py View on Github external
async def _prefix_setter(self, item):
        if inspect.iscoroutinefunction(item):
            item = await item()
        elif callable(item):
            item = item()

        if isinstance(item, (list, tuple)):
            self.prefixes = item
        elif isinstance(item, str):
            self.prefixes = [item]
        else:
            raise ClientError('Invalid prefix provided. A list, tuple, str or callable returning either should be used.')
github TwitchIO / TwitchIO / twitchio / websocket.py View on Github external
for x in self.connections.values():
            if len(x._topics) == 50:
                continue
            elif len(x._topics) + len(topics) > 50:
                continue

            if x._websocket:
                return x

            await x.connect()

            if x._websocket.open:
                return x

            raise WSConnectionFailure('Unable to delegate WebSocket. Please try again.')
        raise ClientError('Maximum PubSub connections established.')
github TwitchIO / TwitchIO / twitchio / ext / commands / bot.py View on Github external
async def _get_prefixes(self, message):
        prefix = ret = self.prefixes
        if callable(prefix):
            ret = prefix(self, message.content)
            if inspect.isawaitable(ret):
                ret = await ret

        if isinstance(ret, (list, tuple)):
            ret = [p for p in ret if p]

        if isinstance(ret, str):
            ret = [ret]

        if not ret:
            raise ClientError('Invalid prefix provided.')

        return ret