diff --git a/aiogram/types/base.py b/aiogram/types/base.py index fd26fb0b..d48d2f49 100644 --- a/aiogram/types/base.py +++ b/aiogram/types/base.py @@ -3,6 +3,7 @@ import typing import ujson from typing import TypeVar +from ..utils.context import get_value from .fields import BaseField PROPS_ATTR_NAME = '_props' @@ -126,6 +127,13 @@ class TelegramObject(metaclass=MetaTelegramObject): """ return cls(**data) + @property + def bot(self): + bot = get_value('bot') + if bot is None: + raise RuntimeError('Can not found bot instance in current context!') + return bot + def to_python(self) -> typing.Dict: """ Get object as JSON serializable