mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 01:15:31 +00:00
Remove context util.
This commit is contained in:
parent
5c1eee4fa9
commit
06fbe0d9cd
18 changed files with 1169 additions and 1333 deletions
|
|
@ -2,9 +2,9 @@ import asyncio
|
|||
|
||||
from aiogram import Bot, types
|
||||
from aiogram.contrib.fsm_storage.redis import RedisStorage2
|
||||
from aiogram.dispatcher import CancelHandler, DEFAULT_RATE_LIMIT, Dispatcher, ctx
|
||||
from aiogram.dispatcher import CancelHandler, DEFAULT_RATE_LIMIT, Dispatcher
|
||||
from aiogram.dispatcher.middlewares import BaseMiddleware
|
||||
from aiogram.utils import context, executor
|
||||
from aiogram.utils import executor
|
||||
from aiogram.utils.exceptions import Throttled
|
||||
|
||||
TOKEN = 'BOT TOKEN HERE'
|
||||
|
|
@ -53,10 +53,10 @@ class ThrottlingMiddleware(BaseMiddleware):
|
|||
:param message:
|
||||
"""
|
||||
# Get current handler
|
||||
handler = context.get_value('handler')
|
||||
# handler = context.get_value('handler')
|
||||
|
||||
# Get dispatcher from context
|
||||
dispatcher = ctx.get_dispatcher()
|
||||
dispatcher = Dispatcher.current()
|
||||
|
||||
# If handler was configured, get rate limit and key from handler
|
||||
if handler:
|
||||
|
|
@ -83,8 +83,8 @@ class ThrottlingMiddleware(BaseMiddleware):
|
|||
:param message:
|
||||
:param throttled:
|
||||
"""
|
||||
handler = context.get_value('handler')
|
||||
dispatcher = ctx.get_dispatcher()
|
||||
# handler = context.get_value('handler')
|
||||
dispatcher = Dispatcher.current()
|
||||
if handler:
|
||||
key = getattr(handler, 'throttling_key', f"{self.prefix}_{handler.__name__}")
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue