How to use the twitchio.cooldowns.RateBucket 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 / http.py View on Github external
def __init__(self, loop, **attrs):
        self.client_id = client_id = attrs.get('client_id', None)

        if not client_id:
            log.warning('Running without client ID, some HTTP endpoints may not work without authentication.')

        self._bucket = RateBucket(method='http')
        self._session = aiohttp.ClientSession(loop=loop)
github TwitchIO / TwitchIO / twitchio / abcs.py View on Github external
def get_bucket(self, channel: str, method: str) -> RateBucket:
        try:
            bucket = self.buckets[channel]
        except KeyError:
            bucket = RateBucket(method=method)
            self.buckets[channel] = bucket

        if bucket.method != method:
            bucket.method = method
            if method == 'mod':
                bucket.limit = bucket.MODLIMIT
            else:
                bucket.limit = bucket.IRCLIMIT

            self.buckets[channel] = bucket

        return bucket