mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Raise Exception if there's no bot instance in context
This commit is contained in:
parent
dd899c9ca0
commit
4e4bbdfc7e
3 changed files with 93 additions and 1 deletions
|
|
@ -142,7 +142,13 @@ class TelegramObject(ContextInstanceMixin, metaclass=MetaTelegramObject):
|
|||
@property
|
||||
def bot(self):
|
||||
from ..bot.bot import Bot
|
||||
return Bot.get_current()
|
||||
|
||||
bot = Bot.get_current()
|
||||
if bot is None:
|
||||
raise RuntimeError("Can't get bot instance from context. "
|
||||
"You can fix it with setting current instance: "
|
||||
"'Bot.set_current(bot_instance)'")
|
||||
return bot
|
||||
|
||||
def to_python(self) -> typing.Dict:
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue