예제 #1
0
    def de_json(cls, data, bot):
        if not data:
            return None

        data['photo'] = ChatPhoto.de_json(data.get('photo'), bot)

        return cls(bot=bot, **data)
예제 #2
0
    def de_json(cls, data, bot):
        if not data:
            return None

        data['photo'] = ChatPhoto.de_json(data.get('photo'), bot)

        return cls(bot=bot, **data)
예제 #3
0
    def de_json(cls, data, bot):
        if not data:
            return None

        data['photo'] = ChatPhoto.de_json(data.get('photo'), bot)
        from telegram import Message
        data['pinned_message'] = Message.de_json(data.get('pinned_message'), bot)

        return cls(bot=bot, **data)
예제 #4
0
    def de_json(cls, data, bot):
        if not data:
            return None

        data['photo'] = ChatPhoto.de_json(data.get('photo'), bot)
        from telegram import Message
        data['pinned_message'] = Message.de_json(data.get('pinned_message'), bot)

        return cls(bot=bot, **data)
예제 #5
0
 def test_de_json(self, bot, chat_photo):
     json_dict = {
         'small_file_id': self.chatphoto_small_file_id,
         'big_file_id': self.chatphoto_big_file_id,
         'small_file_unique_id': self.chatphoto_small_file_unique_id,
         'big_file_unique_id': self.chatphoto_big_file_unique_id,
     }
     chat_photo = ChatPhoto.de_json(json_dict, bot)
     assert chat_photo.small_file_id == self.chatphoto_small_file_id
     assert chat_photo.big_file_id == self.chatphoto_big_file_id
     assert chat_photo.small_file_unique_id == self.chatphoto_small_file_unique_id
     assert chat_photo.big_file_unique_id == self.chatphoto_big_file_unique_id
예제 #6
0
    def de_json(cls, data: JSONDict, bot: 'Bot') -> Optional['Chat']:
        data = cls.parse_data(data)

        if not data:
            return None

        data['photo'] = ChatPhoto.de_json(data.get('photo'), bot)
        from telegram import Message
        data['pinned_message'] = Message.de_json(data.get('pinned_message'), bot)
        data['permissions'] = ChatPermissions.de_json(data.get('permissions'), bot)

        return cls(bot=bot, **data)
예제 #7
0
    def de_json(cls, data, bot):
        if not data:
            return None

        data['photo'] = ChatPhoto.de_json(data.get('photo'), bot)
        from telegram import Message
        pinned_message = data.get('pinned_message')
        if pinned_message:
            pinned_message['default_quote'] = data.get('default_quote')
        data['pinned_message'] = Message.de_json(pinned_message, bot)
        data['permissions'] = ChatPermissions.de_json(data.get('permissions'), bot)

        return cls(bot=bot, **data)
예제 #8
0
    def de_json(data, bot):
        """
        Args:
            data (dict):
            bot (telegram.Bot):

        Returns:
            telegram.Chat:
        """
        if not data:
            return None

        data['photo'] = ChatPhoto.de_json(data.get('photo'), bot)

        return Chat(bot=bot, **data)