mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Removed the use of the context instance (Bot.get_current) from all placements that were used previously. (#1230)
* Removed the use of the context instance (Bot.get_current) from all placements that were used previously. * Fixed tests * Added changelog * Change category
This commit is contained in:
parent
479e302cba
commit
2ecf9cefd7
11 changed files with 45 additions and 49 deletions
|
|
@ -230,7 +230,7 @@ from .session.base import BaseSession
|
|||
T = TypeVar("T")
|
||||
|
||||
|
||||
class Bot(ContextInstanceMixin["Bot"]):
|
||||
class Bot:
|
||||
def __init__(
|
||||
self,
|
||||
token: str,
|
||||
|
|
@ -284,16 +284,14 @@ class Bot(ContextInstanceMixin["Bot"]):
|
|||
"""
|
||||
Generate bot context
|
||||
|
||||
:param auto_close:
|
||||
:param auto_close: close session on exit
|
||||
:return:
|
||||
"""
|
||||
token = self.set_current(self)
|
||||
try:
|
||||
yield self
|
||||
finally:
|
||||
if auto_close:
|
||||
await self.session.close()
|
||||
self.reset_current(token)
|
||||
|
||||
async def me(self) -> User:
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue