Set default values for not specified fields in payload. // TelegramObject

This commit is contained in:
Alex Root Junior 2017-11-28 17:22:46 +02:00
parent 21f35273b7
commit 787ebe3e63

View file

@ -75,12 +75,19 @@ class TelegramObject(metaclass=MetaTelegramObject):
"""
if conf is None:
conf = {}
self._conf = conf
# Load data
for key, value in kwargs.items():
if key in self.props:
self.props[key].set_value(self, value, parent=self)
else:
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
def conf(self) -> typing.Dict[str, typing.Any]: