diff --git a/telegram/base.py b/telegram/base.py index 706ef6622..b8b959eab 100644 --- a/telegram/base.py +++ b/telegram/base.py @@ -70,6 +70,8 @@ class TelegramObject(object): else: data[key] = value + if data.get('from_user'): + data['from'] = data.pop('from_user', None) return data def __eq__(self, other): diff --git a/telegram/callbackquery.py b/telegram/callbackquery.py index 9e2520677..54e5b7576 100644 --- a/telegram/callbackquery.py +++ b/telegram/callbackquery.py @@ -105,13 +105,6 @@ class CallbackQuery(TelegramObject): return cls(bot=bot, **data) - def to_dict(self): - data = super(CallbackQuery, self).to_dict() - - # Required - data['from'] = data.pop('from_user', None) - return data - def answer(self, *args, **kwargs): """Shortcut for:: diff --git a/telegram/choseninlineresult.py b/telegram/choseninlineresult.py index 011cc64ef..f25f91322 100644 --- a/telegram/choseninlineresult.py +++ b/telegram/choseninlineresult.py @@ -79,11 +79,3 @@ class ChosenInlineResult(TelegramObject): data['location'] = Location.de_json(data.get('location'), bot) return cls(**data) - - def to_dict(self): - data = super(ChosenInlineResult, self).to_dict() - - # Required - data['from'] = data.pop('from_user', None) - - return data diff --git a/telegram/inline/inlinequery.py b/telegram/inline/inlinequery.py index 8bcedc900..79b7e127b 100644 --- a/telegram/inline/inlinequery.py +++ b/telegram/inline/inlinequery.py @@ -75,14 +75,6 @@ class InlineQuery(TelegramObject): return cls(bot=bot, **data) - def to_dict(self): - data = super(InlineQuery, self).to_dict() - - # Required - data['from'] = data.pop('from_user', None) - - return data - def answer(self, *args, **kwargs): """Shortcut for:: diff --git a/telegram/message.py b/telegram/message.py index c4686fa07..d36ba32ab 100644 --- a/telegram/message.py +++ b/telegram/message.py @@ -387,7 +387,6 @@ class Message(TelegramObject): data = super(Message, self).to_dict() # Required - data['from'] = data.pop('from_user', None) data['date'] = to_timestamp(self.date) # Optionals if self.forward_date: diff --git a/telegram/payment/precheckoutquery.py b/telegram/payment/precheckoutquery.py index 985c51331..36eebf69a 100644 --- a/telegram/payment/precheckoutquery.py +++ b/telegram/payment/precheckoutquery.py @@ -89,13 +89,6 @@ class PreCheckoutQuery(TelegramObject): return cls(bot=bot, **data) - def to_dict(self): - data = super(PreCheckoutQuery, self).to_dict() - - data['from'] = data.pop('from_user', None) - - return data - def answer(self, *args, **kwargs): """Shortcut for:: diff --git a/telegram/payment/shippingquery.py b/telegram/payment/shippingquery.py index da0c15846..a5b819150 100644 --- a/telegram/payment/shippingquery.py +++ b/telegram/payment/shippingquery.py @@ -66,13 +66,6 @@ class ShippingQuery(TelegramObject): return cls(**data) - def to_dict(self): - data = super(ShippingQuery, self).to_dict() - - data['from'] = data.pop('from_user', None) - - return data - def answer(self, *args, **kwargs): """Shortcut for::