diff --git a/telegram/bot.py b/telegram/bot.py index 5570382c69d..9bc06c5d79a 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -2801,12 +2801,6 @@ def delete_sticker_from_set(self, sticker, timeout=None, **kwargs): return result - @classmethod - def de_json(cls, data, bot): - data = super(Bot, cls).de_json(data, bot) - - return cls(**data) - def to_dict(self): data = {'id': self.id, 'username': self.username, 'first_name': self.username} diff --git a/telegram/forcereply.py b/telegram/forcereply.py index baa6a21454d..92d5c000834 100644 --- a/telegram/forcereply.py +++ b/telegram/forcereply.py @@ -48,10 +48,3 @@ def __init__(self, force_reply=True, selective=False, **kwargs): self.force_reply = bool(force_reply) # Optionals self.selective = bool(selective) - - @classmethod - def de_json(cls, data, bot): - if not data: - return None - - return cls(**data) diff --git a/telegram/inline/inlinekeyboardbutton.py b/telegram/inline/inlinekeyboardbutton.py index 8c578ca74e2..3bb6cba23ab 100644 --- a/telegram/inline/inlinekeyboardbutton.py +++ b/telegram/inline/inlinekeyboardbutton.py @@ -88,23 +88,3 @@ def __init__(self, self.switch_inline_query_current_chat = switch_inline_query_current_chat self.callback_game = callback_game self.pay = pay - - @classmethod - def de_json(cls, data, bot): - data = super(InlineKeyboardButton, cls).de_json(data, bot) - - if not data: - return None - - return cls(**data) - - @classmethod - def de_list(cls, data, bot): - if not data: - return [] - - inline_keyboards = list() - for inline_keyboard in data: - inline_keyboards.append(cls.de_json(inline_keyboard, bot)) - - return inline_keyboards diff --git a/telegram/inline/inlinekeyboardmarkup.py b/telegram/inline/inlinekeyboardmarkup.py index a6f5dd639da..229aef8362e 100644 --- a/telegram/inline/inlinekeyboardmarkup.py +++ b/telegram/inline/inlinekeyboardmarkup.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains an object that represents a Telegram InlineKeyboardMarkup.""" -from telegram import ReplyMarkup, InlineKeyboardButton +from telegram import ReplyMarkup class InlineKeyboardMarkup(ReplyMarkup): @@ -39,20 +39,6 @@ def __init__(self, inline_keyboard, **kwargs): # Required self.inline_keyboard = inline_keyboard - @classmethod - def de_json(cls, data, bot): - data = super(InlineKeyboardMarkup, cls).de_json(data, bot) - - if not data: - return None - - data['inline_keyboard'] = [ - InlineKeyboardButton.de_list(inline_keyboard, bot) - for inline_keyboard in data['inline_keyboard'] - ] - - return cls(**data) - def to_dict(self): data = super(InlineKeyboardMarkup, self).to_dict() diff --git a/telegram/inline/inlinequeryresultarticle.py b/telegram/inline/inlinequeryresultarticle.py index b00790ed543..af0f33433d7 100644 --- a/telegram/inline/inlinequeryresultarticle.py +++ b/telegram/inline/inlinequeryresultarticle.py @@ -19,7 +19,7 @@ """This module contains the classes that represent Telegram InlineQueryResultArticle""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultArticle(InlineQueryResult): @@ -91,16 +91,3 @@ def __init__(self, self.thumb_width = thumb_width if thumb_height: self.thumb_height = thumb_height - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultArticle, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultaudio.py b/telegram/inline/inlinequeryresultaudio.py index 87cac4a9a53..f37e12cc0a5 100644 --- a/telegram/inline/inlinequeryresultaudio.py +++ b/telegram/inline/inlinequeryresultaudio.py @@ -19,7 +19,7 @@ """This module contains the classes that represent Telegram InlineQueryResultAudio""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultAudio(InlineQueryResult): @@ -82,16 +82,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultAudio, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultcachedaudio.py b/telegram/inline/inlinequeryresultcachedaudio.py index 41bfca0f39b..949d0d701c7 100644 --- a/telegram/inline/inlinequeryresultcachedaudio.py +++ b/telegram/inline/inlinequeryresultcachedaudio.py @@ -19,7 +19,7 @@ """This module contains the classes that represent Telegram InlineQueryResultCachedAudio""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultCachedAudio(InlineQueryResult): @@ -67,16 +67,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultCachedAudio, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultcacheddocument.py b/telegram/inline/inlinequeryresultcacheddocument.py index 84684b5cbb5..289d8735cf0 100644 --- a/telegram/inline/inlinequeryresultcacheddocument.py +++ b/telegram/inline/inlinequeryresultcacheddocument.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains the classes that represent Telegram InlineQueryResultCachedDocument""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultCachedDocument(InlineQueryResult): @@ -75,16 +75,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultCachedDocument, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultcachedgif.py b/telegram/inline/inlinequeryresultcachedgif.py index d45f68f01c2..16516a96f41 100644 --- a/telegram/inline/inlinequeryresultcachedgif.py +++ b/telegram/inline/inlinequeryresultcachedgif.py @@ -19,7 +19,7 @@ """This module contains the classes that represent Telegram InlineQueryResultCachedGif""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultCachedGif(InlineQueryResult): @@ -73,16 +73,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultCachedGif, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultcachedmpeg4gif.py b/telegram/inline/inlinequeryresultcachedmpeg4gif.py index 9c78091c172..2fc5c8fb8a4 100644 --- a/telegram/inline/inlinequeryresultcachedmpeg4gif.py +++ b/telegram/inline/inlinequeryresultcachedmpeg4gif.py @@ -19,7 +19,7 @@ """This module contains the classes that represent Telegram InlineQueryResultMpeg4Gif""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultCachedMpeg4Gif(InlineQueryResult): @@ -73,16 +73,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultCachedMpeg4Gif, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultcachedphoto.py b/telegram/inline/inlinequeryresultcachedphoto.py index 7e4b7f92dd5..18dad402e11 100644 --- a/telegram/inline/inlinequeryresultcachedphoto.py +++ b/telegram/inline/inlinequeryresultcachedphoto.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains the classes that represent Telegram InlineQueryResultPhoto""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultCachedPhoto(InlineQueryResult): @@ -77,16 +77,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultCachedPhoto, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultcachedsticker.py b/telegram/inline/inlinequeryresultcachedsticker.py index 1ebd5c1403c..972863dc44a 100644 --- a/telegram/inline/inlinequeryresultcachedsticker.py +++ b/telegram/inline/inlinequeryresultcachedsticker.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains the classes that represent Telegram InlineQueryResultCachedSticker""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultCachedSticker(InlineQueryResult): @@ -61,16 +61,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultCachedSticker, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultcachedvideo.py b/telegram/inline/inlinequeryresultcachedvideo.py index a9169c86cae..b02021ca862 100644 --- a/telegram/inline/inlinequeryresultcachedvideo.py +++ b/telegram/inline/inlinequeryresultcachedvideo.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains the classes that represent Telegram InlineQueryResultCachedVideo""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultCachedVideo(InlineQueryResult): @@ -76,16 +76,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultCachedVideo, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultcachedvoice.py b/telegram/inline/inlinequeryresultcachedvoice.py index 1d58d6b6076..8ae6f4e8266 100644 --- a/telegram/inline/inlinequeryresultcachedvoice.py +++ b/telegram/inline/inlinequeryresultcachedvoice.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains the classes that represent Telegram InlineQueryResultCachedVoice""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultCachedVoice(InlineQueryResult): @@ -70,16 +70,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultCachedVoice, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultcontact.py b/telegram/inline/inlinequeryresultcontact.py index 6d551bd002a..274840a4048 100644 --- a/telegram/inline/inlinequeryresultcontact.py +++ b/telegram/inline/inlinequeryresultcontact.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains the classes that represent Telegram InlineQueryResultContact""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultContact(InlineQueryResult): @@ -86,16 +86,3 @@ def __init__(self, self.thumb_width = thumb_width if thumb_height: self.thumb_height = thumb_height - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultContact, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultdocument.py b/telegram/inline/inlinequeryresultdocument.py index f60e0b363f6..033d8ff1e6f 100644 --- a/telegram/inline/inlinequeryresultdocument.py +++ b/telegram/inline/inlinequeryresultdocument.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains the classes that represent Telegram InlineQueryResultDocument""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultDocument(InlineQueryResult): @@ -97,16 +97,3 @@ def __init__(self, self.thumb_width = thumb_width if thumb_height: self.thumb_height = thumb_height - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultDocument, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultgame.py b/telegram/inline/inlinequeryresultgame.py index 7b895d9bdb3..0e00a9282ed 100644 --- a/telegram/inline/inlinequeryresultgame.py +++ b/telegram/inline/inlinequeryresultgame.py @@ -19,7 +19,7 @@ """This module contains the classes that represent Telegram InlineQueryResultGame""" -from telegram import InlineQueryResult, InlineKeyboardMarkup +from telegram import InlineQueryResult class InlineQueryResultGame(InlineQueryResult): @@ -49,14 +49,3 @@ def __init__(self, id, game_short_name, reply_markup=None, **kwargs): if reply_markup: self.reply_markup = reply_markup - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultGame, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultgif.py b/telegram/inline/inlinequeryresultgif.py index 230ef91bbf7..d2302aebde5 100644 --- a/telegram/inline/inlinequeryresultgif.py +++ b/telegram/inline/inlinequeryresultgif.py @@ -19,7 +19,7 @@ """This module contains the classes that represent Telegram InlineQueryResultGif""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultGif(InlineQueryResult): @@ -92,16 +92,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultGif, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultlocation.py b/telegram/inline/inlinequeryresultlocation.py index c1de9fd0d04..d3c58726349 100644 --- a/telegram/inline/inlinequeryresultlocation.py +++ b/telegram/inline/inlinequeryresultlocation.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains the classes that represent Telegram InlineQueryResultLocation""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultLocation(InlineQueryResult): @@ -85,16 +85,3 @@ def __init__(self, self.thumb_width = thumb_width if thumb_height: self.thumb_height = thumb_height - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultLocation, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultmpeg4gif.py b/telegram/inline/inlinequeryresultmpeg4gif.py index 657adff7454..97faf2b74a7 100644 --- a/telegram/inline/inlinequeryresultmpeg4gif.py +++ b/telegram/inline/inlinequeryresultmpeg4gif.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains the classes that represent Telegram InlineQueryResultMpeg4Gif""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultMpeg4Gif(InlineQueryResult): @@ -92,16 +92,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultMpeg4Gif, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultphoto.py b/telegram/inline/inlinequeryresultphoto.py index a62a56dffd5..523fdba5f7b 100644 --- a/telegram/inline/inlinequeryresultphoto.py +++ b/telegram/inline/inlinequeryresultphoto.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains the classes that represent Telegram InlineQueryResultPhoto""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultPhoto(InlineQueryResult): @@ -92,16 +92,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultPhoto, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultvenue.py b/telegram/inline/inlinequeryresultvenue.py index 96e9ea3bb8b..1dada9c7cdc 100644 --- a/telegram/inline/inlinequeryresultvenue.py +++ b/telegram/inline/inlinequeryresultvenue.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains the classes that represent Telegram InlineQueryResultVenue""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultVenue(InlineQueryResult): @@ -94,16 +94,3 @@ def __init__(self, self.thumb_width = thumb_width if thumb_height: self.thumb_height = thumb_height - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultVenue, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultvideo.py b/telegram/inline/inlinequeryresultvideo.py index a7a0a3aeb61..c4f16c3cc52 100644 --- a/telegram/inline/inlinequeryresultvideo.py +++ b/telegram/inline/inlinequeryresultvideo.py @@ -19,7 +19,7 @@ """This module contains the classes that represent Telegram InlineQueryResultVideo""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultVideo(InlineQueryResult): @@ -101,16 +101,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultVideo, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inlinequeryresultvoice.py b/telegram/inline/inlinequeryresultvoice.py index 0798fd6201f..7f555f068d8 100644 --- a/telegram/inline/inlinequeryresultvoice.py +++ b/telegram/inline/inlinequeryresultvoice.py @@ -19,7 +19,7 @@ """This module contains the classes that represent Telegram InlineQueryResultVoice""" -from telegram import InlineQueryResult, InlineKeyboardMarkup, InputMessageContent +from telegram import InlineQueryResult class InlineQueryResultVoice(InlineQueryResult): @@ -78,16 +78,3 @@ def __init__(self, self.reply_markup = reply_markup if input_message_content: self.input_message_content = input_message_content - - @classmethod - def de_json(cls, data, bot): - data = super(InlineQueryResultVoice, cls).de_json(data, bot) - - if not data: - return None - - data['reply_markup'] = InlineKeyboardMarkup.de_json(data.get('reply_markup'), bot) - data['input_message_content'] = InputMessageContent.de_json( - data.get('input_message_content'), bot) - - return cls(**data) diff --git a/telegram/inline/inputcontactmessagecontent.py b/telegram/inline/inputcontactmessagecontent.py index 8e6bad0ec16..521d86210d3 100644 --- a/telegram/inline/inputcontactmessagecontent.py +++ b/telegram/inline/inputcontactmessagecontent.py @@ -44,7 +44,3 @@ def __init__(self, phone_number, first_name, last_name=None, **kwargs): self.first_name = first_name # Optionals self.last_name = last_name - - @classmethod - def de_json(cls, data, bot): - return cls(**data) diff --git a/telegram/inline/inputlocationmessagecontent.py b/telegram/inline/inputlocationmessagecontent.py index 58f21cc48b0..b337fce597b 100644 --- a/telegram/inline/inputlocationmessagecontent.py +++ b/telegram/inline/inputlocationmessagecontent.py @@ -40,7 +40,3 @@ def __init__(self, latitude, longitude, **kwargs): # Required self.latitude = latitude self.longitude = longitude - - @classmethod - def de_json(cls, data, bot): - return cls(**data) diff --git a/telegram/inline/inputmessagecontent.py b/telegram/inline/inputmessagecontent.py index 9d105e85af2..baa9cb596bc 100644 --- a/telegram/inline/inputmessagecontent.py +++ b/telegram/inline/inputmessagecontent.py @@ -29,36 +29,4 @@ class InputMessageContent(TelegramObject): :class:`telegram.InputLocationMessageContent`, :class:`telegram.InputTextMessageContent` and :class:`telegram.InputVenueMessageContent` for more details. """ - - @classmethod - def de_json(cls, data, bot): - data = super(InputMessageContent, cls).de_json(data, bot) - - if not data: - return None - - try: - from telegram import InputTextMessageContent - return InputTextMessageContent.de_json(data, bot) - except TypeError: - pass - - try: - from telegram import InputVenueMessageContent - return InputVenueMessageContent.de_json(data, bot) - except TypeError: - pass - - try: - from telegram import InputLocationMessageContent - return InputLocationMessageContent.de_json(data, bot) - except TypeError: - pass - - try: - from telegram import InputContactMessageContent - return InputContactMessageContent.de_json(data, bot) - except TypeError: - pass - - return None + pass diff --git a/telegram/inline/inputtextmessagecontent.py b/telegram/inline/inputtextmessagecontent.py index d2947fa8e2d..bb6d7f4deb8 100644 --- a/telegram/inline/inputtextmessagecontent.py +++ b/telegram/inline/inputtextmessagecontent.py @@ -49,7 +49,3 @@ def __init__(self, message_text, parse_mode=None, disable_web_page_preview=None, # Optionals self.parse_mode = parse_mode self.disable_web_page_preview = disable_web_page_preview - - @classmethod - def de_json(cls, data, bot): - return cls(**data) diff --git a/telegram/inline/inputvenuemessagecontent.py b/telegram/inline/inputvenuemessagecontent.py index d0be0824ca9..09d8063876a 100644 --- a/telegram/inline/inputvenuemessagecontent.py +++ b/telegram/inline/inputvenuemessagecontent.py @@ -50,7 +50,3 @@ def __init__(self, latitude, longitude, title, address, foursquare_id=None, **kw self.address = address # Optionals self.foursquare_id = foursquare_id - - @classmethod - def de_json(cls, data, bot): - return cls(**data) diff --git a/telegram/keyboardbutton.py b/telegram/keyboardbutton.py index f413d28bfb3..2e19b56b97e 100644 --- a/telegram/keyboardbutton.py +++ b/telegram/keyboardbutton.py @@ -53,21 +53,3 @@ def __init__(self, text, request_contact=None, request_location=None, **kwargs): # Optionals self.request_contact = request_contact self.request_location = request_location - - @classmethod - def de_json(cls, data, bot): - if not data: - return None - - return cls(**data) - - @classmethod - def de_list(cls, data, bot): - if not data: - return [] - - keyboards = list() - for keyboard in data: - keyboards.append(cls.de_json(keyboard, bot)) - - return keyboards diff --git a/telegram/payment/labeledprice.py b/telegram/payment/labeledprice.py index 244f42d14d7..b77a3c7deaa 100644 --- a/telegram/payment/labeledprice.py +++ b/telegram/payment/labeledprice.py @@ -41,21 +41,3 @@ class LabeledPrice(TelegramObject): def __init__(self, label, amount, **kwargs): self.label = label self.amount = amount - - @classmethod - def de_json(cls, data, bot): - if not data: - return None - - return cls(**data) - - @classmethod - def de_list(cls, data, bot): - if not data: - return [] - - labeled_prices = list() - for labeled_price in data: - labeled_prices.append(cls.de_json(labeled_price, bot)) - - return labeled_prices diff --git a/telegram/payment/shippingoption.py b/telegram/payment/shippingoption.py index d69511a621e..c79463f2d7e 100644 --- a/telegram/payment/shippingoption.py +++ b/telegram/payment/shippingoption.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains an object that represents a Telegram ShippingOption.""" -from telegram import TelegramObject, LabeledPrice +from telegram import TelegramObject class ShippingOption(TelegramObject): @@ -44,17 +44,6 @@ def __init__(self, id, title, prices, **kwargs): self._id_attrs = (self.id,) - @classmethod - def de_json(cls, data, bot): - if not data: - return None - - data = super(ShippingOption, cls).de_json(data, bot) - - data['prices'] = LabeledPrice.de_list(data.get('prices'), bot) - - return cls(**data) - def to_dict(self): data = super(ShippingOption, self).to_dict() diff --git a/telegram/replykeyboardmarkup.py b/telegram/replykeyboardmarkup.py index 1e235cc2558..1b86e633a4f 100644 --- a/telegram/replykeyboardmarkup.py +++ b/telegram/replykeyboardmarkup.py @@ -18,7 +18,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains an object that represents a Telegram ReplyKeyboardMarkup.""" -from telegram import ReplyMarkup, KeyboardButton +from telegram import ReplyMarkup class ReplyKeyboardMarkup(ReplyMarkup): @@ -72,17 +72,6 @@ def __init__(self, self.one_time_keyboard = bool(one_time_keyboard) self.selective = bool(selective) - @classmethod - def de_json(cls, data, bot): - if not data: - return None - - data = super(ReplyKeyboardMarkup, cls).de_json(data, bot) - - data['keyboard'] = [KeyboardButton.de_list(keyboard, bot) for keyboard in data['keyboard']] - - return cls(**data) - def to_dict(self): data = super(ReplyKeyboardMarkup, self).to_dict() diff --git a/telegram/replykeyboardremove.py b/telegram/replykeyboardremove.py index 215c2ec74d7..bea44da8f85 100644 --- a/telegram/replykeyboardremove.py +++ b/telegram/replykeyboardremove.py @@ -53,10 +53,3 @@ def __init__(self, selective=False, **kwargs): self.remove_keyboard = True # Optionals self.selective = bool(selective) - - @classmethod - def de_json(cls, data, bot): - if not data: - return None - - return cls(**data) diff --git a/tests/test_inlinekeyboardbutton.py b/tests/test_inlinekeyboardbutton.py index b187d7084ff..dba8f5ce417 100644 --- a/tests/test_inlinekeyboardbutton.py +++ b/tests/test_inlinekeyboardbutton.py @@ -43,19 +43,7 @@ class TestInlineKeyboardButton(object): callback_game = 'callback_game' pay = 'pay' - def test_de_json(self, bot): - json_dict = { - 'text': self.text, - 'url': self.url, - 'callback_data': self.callback_data, - 'switch_inline_query': self.switch_inline_query, - 'switch_inline_query_current_chat': - self.switch_inline_query_current_chat, - 'callback_game': self.callback_game, - 'pay': self.pay - } - inline_keyboard_button = InlineKeyboardButton.de_json(json_dict, bot) - + def test_expected_values(self, inline_keyboard_button): assert inline_keyboard_button.text == self.text assert inline_keyboard_button.url == self.url assert inline_keyboard_button.callback_data == self.callback_data @@ -65,12 +53,6 @@ def test_de_json(self, bot): assert inline_keyboard_button.callback_game == self.callback_game assert inline_keyboard_button.pay == self.pay - def test_de_list(self, bot, inline_keyboard_button): - keyboard_json = [inline_keyboard_button.to_dict(), inline_keyboard_button.to_dict()] - inline_keyboard_buttons = InlineKeyboardButton.de_list(keyboard_json, bot) - - assert inline_keyboard_buttons == [inline_keyboard_button, inline_keyboard_button] - def test_to_dict(self, inline_keyboard_button): inline_keyboard_button_dict = inline_keyboard_button.to_dict() diff --git a/tests/test_inlinekeyboardmarkup.py b/tests/test_inlinekeyboardmarkup.py index acc72bca393..77484a81802 100644 --- a/tests/test_inlinekeyboardmarkup.py +++ b/tests/test_inlinekeyboardmarkup.py @@ -41,16 +41,8 @@ def test_send_message_with_inline_keyboard_markup(self, bot, chat_id, inline_key assert message.text == 'Testing InlineKeyboardMarkup' - def test_de_json(self, bot, inline_keyboard_markup): - json_dict = { - 'inline_keyboard': [[ - self.inline_keyboard[0][0].to_dict(), - self.inline_keyboard[0][1].to_dict() - ]], - } - inline_keyboard_markup_json = InlineKeyboardMarkup.de_json(json_dict, bot) - - assert inline_keyboard_markup_json.to_dict() == inline_keyboard_markup.to_dict() + def test_expected_values(self, inline_keyboard_markup): + assert inline_keyboard_markup.inline_keyboard == self.inline_keyboard def test_to_dict(self, inline_keyboard_markup): inline_keyboard_markup_dict = inline_keyboard_markup.to_dict() diff --git a/tests/test_inputcontactmessagecontent.py b/tests/test_inputcontactmessagecontent.py index 1373820e9af..66889ce8631 100644 --- a/tests/test_inputcontactmessagecontent.py +++ b/tests/test_inputcontactmessagecontent.py @@ -19,16 +19,7 @@ import pytest -from telegram import InputContactMessageContent, InputMessageContent - - -@pytest.fixture(scope='function') -def json_dict(): - return { - 'first_name': TestInputContactMessageContent.first_name, - 'phone_number': TestInputContactMessageContent.phone_number, - 'last_name': TestInputContactMessageContent.last_name, - } +from telegram import InputContactMessageContent @pytest.fixture(scope='class') @@ -43,25 +34,10 @@ class TestInputContactMessageContent(object): first_name = 'first name' last_name = 'last name' - def test_de_json(self, json_dict, bot): - input_contact_message_content_json = InputContactMessageContent.de_json(json_dict, bot) - - assert input_contact_message_content_json.first_name == self.first_name - assert input_contact_message_content_json.phone_number == self.phone_number - assert input_contact_message_content_json.last_name == self.last_name - - def test_de_json_factory(self, json_dict, bot): - input_contact_message_content_json = InputMessageContent.de_json(json_dict, bot) - - assert isinstance(input_contact_message_content_json, InputContactMessageContent) - - def test_de_json_factory_without_required_args(self, json_dict, bot): - del (json_dict['phone_number']) - del (json_dict['first_name']) - - input_contact_message_content_json = InputMessageContent.de_json(json_dict, bot) - - assert input_contact_message_content_json is None + def test_expected_values(self, input_contact_message_content): + assert input_contact_message_content.first_name == self.first_name + assert input_contact_message_content.phone_number == self.phone_number + assert input_contact_message_content.last_name == self.last_name def test_to_dict(self, input_contact_message_content): input_contact_message_content_dict = input_contact_message_content.to_dict() diff --git a/tests/test_inputlocationmessagecontent.py b/tests/test_inputlocationmessagecontent.py index f2a833e60b4..0af425b7825 100644 --- a/tests/test_inputlocationmessagecontent.py +++ b/tests/test_inputlocationmessagecontent.py @@ -19,46 +19,22 @@ import pytest -from telegram import InputMessageContent, InputLocationMessageContent - - -@pytest.fixture(scope='function') -def json_dict(): - return { - 'longitude': TestInputLocationMessageContent.longitude, - 'latitude': TestInputLocationMessageContent.latitude, - } +from telegram import InputLocationMessageContent @pytest.fixture(scope='class') def input_location_message_content(): - return InputLocationMessageContent(TestInputLocationMessageContent.longitude, - TestInputLocationMessageContent.latitude) + return InputLocationMessageContent(TestInputLocationMessageContent.latitude, + TestInputLocationMessageContent.longitude) class TestInputLocationMessageContent(object): - latitude = 1. - longitude = 2. - - def test_de_json(self, json_dict, bot): - input_location_message_content_json = InputLocationMessageContent.de_json(json_dict, bot) - - assert input_location_message_content_json.longitude == self.longitude - assert input_location_message_content_json.latitude == self.latitude - - def test_input_location_message_content_json_de_json_factory(self, json_dict, bot): - input_location_message_content_json = InputMessageContent.de_json(json_dict, bot) - - assert isinstance(input_location_message_content_json, InputLocationMessageContent) - - def test_de_json_factory_without_required_args(self, json_dict, bot): - del (json_dict['longitude']) - # If no args are passed it will fall in a different condition - # del (json_dict['latitude']) - - input_location_message_content_json = InputMessageContent.de_json(json_dict, bot) + latitude = -23.691288 + longitude = -46.788279 - assert input_location_message_content_json is None + def test_expected_values(self, input_location_message_content): + assert input_location_message_content.longitude == self.longitude + assert input_location_message_content.latitude == self.latitude def test_to_dict(self, input_location_message_content): input_location_message_content_dict = input_location_message_content.to_dict() diff --git a/tests/test_inputmessagecontent.py b/tests/test_inputmessagecontent.py deleted file mode 100644 index 738638c2364..00000000000 --- a/tests/test_inputmessagecontent.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python -# -# A library that provides a Python interface to the Telegram Bot API -# Copyright (C) 2015-2017 -# Leandro Toledo de Souza -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser Public License for more details. -# -# You should have received a copy of the GNU Lesser Public License -# along with this program. If not, see [http://www.gnu.org/licenses/]. - -from telegram import InputMessageContent - - -class TestInputMessageContent(object): - def test_de_json(self, bot): - input_message_content = InputMessageContent.de_json(None, bot) - - assert input_message_content is None diff --git a/tests/test_inputtextmessagecontent.py b/tests/test_inputtextmessagecontent.py index d0f8829f7c5..1acc610ecce 100644 --- a/tests/test_inputtextmessagecontent.py +++ b/tests/test_inputtextmessagecontent.py @@ -19,16 +19,7 @@ import pytest -from telegram import InputTextMessageContent, InputMessageContent, ParseMode - - -@pytest.fixture(scope='function') -def json_dict(): - return { - 'parse_mode': TestInputTextMessageContent.parse_mode, - 'message_text': TestInputTextMessageContent.message_text, - 'disable_web_page_preview': TestInputTextMessageContent.disable_web_page_preview, - } +from telegram import InputTextMessageContent, ParseMode @pytest.fixture(scope='class') @@ -43,25 +34,10 @@ class TestInputTextMessageContent(object): parse_mode = ParseMode.MARKDOWN disable_web_page_preview = True - def test_de_json(self, json_dict, bot): - input_text_message_content_json = InputTextMessageContent.de_json(json_dict, bot) - - assert input_text_message_content_json.parse_mode == self.parse_mode - assert input_text_message_content_json.message_text == self.message_text - assert input_text_message_content_json.disable_web_page_preview == \ - self.disable_web_page_preview - - def test_input_text_message_content_json_de_json_factory(self, json_dict, bot): - input_text_message_content_json = InputMessageContent.de_json(json_dict, bot) - - assert isinstance(input_text_message_content_json, InputTextMessageContent) - - def test_de_json_factory_without_required_args(self, json_dict, bot): - del (json_dict['message_text']) - - input_text_message_content_json = InputMessageContent.de_json(json_dict, bot) - - assert input_text_message_content_json is None + def test_expected_values(self, input_text_message_content): + assert input_text_message_content.parse_mode == self.parse_mode + assert input_text_message_content.message_text == self.message_text + assert input_text_message_content.disable_web_page_preview == self.disable_web_page_preview def test_to_dict(self, input_text_message_content): input_text_message_content_dict = input_text_message_content.to_dict() diff --git a/tests/test_inputvenuemessagecontent.py b/tests/test_inputvenuemessagecontent.py index 2bbe39ce704..f26d25e9ce0 100644 --- a/tests/test_inputvenuemessagecontent.py +++ b/tests/test_inputvenuemessagecontent.py @@ -19,18 +19,7 @@ import pytest -from telegram import InputVenueMessageContent, InputMessageContent - - -@pytest.fixture(scope='function') -def json_dict(): - return { - 'longitude': TestInputVenueMessageContent.longitude, - 'latitude': TestInputVenueMessageContent.latitude, - 'title': TestInputVenueMessageContent.title, - 'address': TestInputVenueMessageContent.address, - 'foursquare_id': TestInputVenueMessageContent.foursquare_id, - } +from telegram import InputVenueMessageContent @pytest.fixture(scope='class') @@ -49,31 +38,12 @@ class TestInputVenueMessageContent(object): address = 'address' foursquare_id = 'foursquare id' - def test_de_json(self, json_dict, bot): - input_venue_message_content_json = InputVenueMessageContent.de_json(json_dict, bot) - - assert input_venue_message_content_json.longitude == self.longitude - assert input_venue_message_content_json.latitude == self.latitude - assert input_venue_message_content_json.title == self.title - assert input_venue_message_content_json.address == self.address - assert input_venue_message_content_json.foursquare_id == self.foursquare_id - - def test_de_json_factory(self, json_dict, bot): - input_venue_message_content_json = InputMessageContent.de_json(json_dict, bot) - - assert isinstance(input_venue_message_content_json, InputVenueMessageContent) - - def test_de_json_factory_without_required_args(self, json_dict, bot): - json_dict = json_dict - - del (json_dict['longitude']) - del (json_dict['latitude']) - del (json_dict['title']) - del (json_dict['address']) - - input_venue_message_content_json = InputMessageContent.de_json(json_dict, bot) - - assert input_venue_message_content_json is None + def test_expected_values(self, input_venue_message_content): + assert input_venue_message_content.longitude == self.longitude + assert input_venue_message_content.latitude == self.latitude + assert input_venue_message_content.title == self.title + assert input_venue_message_content.address == self.address + assert input_venue_message_content.foursquare_id == self.foursquare_id def test_to_dict(self, input_venue_message_content): input_venue_message_content_dict = input_venue_message_content.to_dict() diff --git a/tests/test_keyboardbutton.py b/tests/test_keyboardbutton.py index 117affcf253..9c9931c4ce6 100644 --- a/tests/test_keyboardbutton.py +++ b/tests/test_keyboardbutton.py @@ -39,12 +39,6 @@ def test_expected_values(self, keyboard_button): assert keyboard_button.request_location == self.request_location assert keyboard_button.request_contact == self.request_contact - def test_de_list(self, bot, keyboard_button): - keyboard_json = [keyboard_button.to_dict(), keyboard_button.to_dict()] - inline_keyboard_buttons = KeyboardButton.de_list(keyboard_json, bot) - - assert inline_keyboard_buttons == [keyboard_button, keyboard_button] - def test_to_dict(self, keyboard_button): keyboard_button_dict = keyboard_button.to_dict() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy