mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
Set default values for not specified fields in payload. // TelegramObject
This commit is contained in:
parent
21f35273b7
commit
787ebe3e63
1 changed files with 8 additions and 1 deletions
|
|
@ -75,12 +75,19 @@ class TelegramObject(metaclass=MetaTelegramObject):
|
||||||
"""
|
"""
|
||||||
if conf is None:
|
if conf is None:
|
||||||
conf = {}
|
conf = {}
|
||||||
|
self._conf = conf
|
||||||
|
|
||||||
|
# Load data
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
if key in self.props:
|
if key in self.props:
|
||||||
self.props[key].set_value(self, value, parent=self)
|
self.props[key].set_value(self, value, parent=self)
|
||||||
else:
|
else:
|
||||||
self.values[key] = value
|
self.values[key] = value
|
||||||
self._conf = conf
|
|
||||||
|
# Load default values
|
||||||
|
for key, value in self.props.items():
|
||||||
|
if value.default and key not in self.values:
|
||||||
|
self.values[key] = value.default
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def conf(self) -> typing.Dict[str, typing.Any]:
|
def conf(self) -> typing.Dict[str, typing.Any]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue