Merge pull request #91 from jh0ker/useroptional

Make user_from optional to work with channels channels
This commit is contained in:
Leandro Toledo 2015-11-04 09:52:00 -02:00
commit d3d5c1e907

View file

@ -134,7 +134,7 @@ class Message(TelegramObject):
if not data:
return None
data['from_user'] = User.de_json(data['from'])
data['from_user'] = User.de_json(data.get('from'))
data['date'] = datetime.fromtimestamp(data['date'])
if 'first_name' in data.get('chat', ''):
data['chat'] = User.de_json(data.get('chat'))
@ -185,7 +185,7 @@ class Message(TelegramObject):
data = super(Message, self).to_dict()
# Required
data['from'] = data.pop('from_user')
data['from'] = data.pop('from_user', None)
data['date'] = self._totimestamp(self.date)
# Optionals
if self.forward_date: