Fix empty bucket return

When trying to implement throttling for commands "hr = await dispatcher.check_key(key)" without other parameters it couldn't find any bucket
This commit is contained in:
PavelMinev 2021-02-20 12:43:57 +00:00 committed by GitHub
parent 9de257efec
commit 9f23c739be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1136,8 +1136,8 @@ class Dispatcher(DataMixin, ContextInstanceMixin):
raise RuntimeError('This storage does not provide Leaky Bucket')
if user_id is None and chat_id is None:
user_id = types.User.get_current()
chat_id = types.Chat.get_current()
user_id = types.User.get_current().id
chat_id = types.Chat.get_current().id
bucket = await self.storage.get_bucket(chat=chat_id, user=user_id)
data = bucket.get(key, {})
@ -1158,8 +1158,8 @@ class Dispatcher(DataMixin, ContextInstanceMixin):
raise RuntimeError('This storage does not provide Leaky Bucket')
if user_id is None and chat_id is None:
user_id = types.User.get_current()
chat_id = types.Chat.get_current()
user_id = types.User.get_current().id
chat_id = types.Chat.get_current().id
bucket = await self.storage.get_bucket(chat=chat_id, user=user_id)
if bucket and key in bucket: