mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-11 18:01:04 +00:00
Bot getter in TelegramObject.
This commit is contained in:
parent
14d250bfbd
commit
d98566bf7f
1 changed files with 8 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ import typing
|
||||||
import ujson
|
import ujson
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
|
from ..utils.context import get_value
|
||||||
from .fields import BaseField
|
from .fields import BaseField
|
||||||
|
|
||||||
PROPS_ATTR_NAME = '_props'
|
PROPS_ATTR_NAME = '_props'
|
||||||
|
|
@ -126,6 +127,13 @@ class TelegramObject(metaclass=MetaTelegramObject):
|
||||||
"""
|
"""
|
||||||
return cls(**data)
|
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:
|
def to_python(self) -> typing.Dict:
|
||||||
"""
|
"""
|
||||||
Get object as JSON serializable
|
Get object as JSON serializable
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue