From 9f23c739be957ad29611c67e22737184e16550c5 Mon Sep 17 00:00:00 2001 From: PavelMinev <31959768+PavelMinev@users.noreply.github.com> Date: Sat, 20 Feb 2021 12:43:57 +0000 Subject: [PATCH] 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 --- aiogram/dispatcher/dispatcher.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aiogram/dispatcher/dispatcher.py b/aiogram/dispatcher/dispatcher.py index b38d3af1..cc9507bc 100644 --- a/aiogram/dispatcher/dispatcher.py +++ b/aiogram/dispatcher/dispatcher.py @@ -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: