示例#1
0
    def from_dict(cls, dct):
        e = cls()
        e.color = dct.get('color')
        e.title = dct.get('title')
        e.description = dct.get('description')
        e.url = dct.get('url')

        if dct.get('author'):
            auth = dct['author']
            author = MessageEmbedAuthor()
            author.name = auth.get('name')
            author.url = auth.get('url')
            author.icon_url = auth.get('icon_url')
            e.author = author

        if dct.get('thumbnail'):
            thumb = dct['thumbnail']
            thumbnail = MessageEmbedThumbnail()
            thumbnail.url = thumb.get('url')
            thumbnail.proxy_url = thumb.get('proxy_url')
            thumbnail.width = thumb.get('width')
            thumbnail.height = thumb.get('height')
            e.thumbnail = thumbnail

        if dct.get('image'):
            img = dct['image']
            image = MessageEmbedImage()
            image.url = img.get('url')
            image.proxy_url = img.get('proxy_url')
            e.image = image

        if dct.get('footer'):
            foot = dct['footer']
            footer = MessageEmbedFooter()
            footer.text = foot.get('text')
            e.footer = footer
        else:
            footer = MessageEmbedFooter()
            footer.text = 'Mee6'
            e.footer = footer

        for f in dct.get('fields', ()):
            field = MessageEmbedField()
            field.name = f.get('name')
            field.value = f.get('value')
            field.inline = f.get('inline')
            e.fields.append(field)

        return e
示例#2
0
文件: base.py 项目: Defaulttt/mee6
    def embed(self):
        e = MessageEmbed()
        e.color = self.color
        e.title = self.stream_title
        e.url = self.stream_url

        author = MessageEmbedAuthor()
        author.name = self.display_name
        author.url = self.stream_url
        author.icon_url = self.avatar
        e.author = author

        thumbnail = MessageEmbedThumbnail()
        thumbnail.url = self.avatar
        thumbnail.proxy_url = self.avatar
        thumbnail.width, thumbnail.height = 100, 100
        e.thumbnail = thumbnail

        image = MessageEmbedImage()
        image.url = self.stream_preview + '?rand={}'.format(randint(0, 999999))
        e.image = image

        footer = MessageEmbedFooter()
        footer.text = self.platform_name
        e.footer = footer

        if self.stream_game:
            game_field = MessageEmbedField()
            game_field.name = 'Played Game'
            game_field.value = self.stream_game
            game_field.inline = True
            e.fields.append(game_field)

        if self.stream_viewers_count or self.stream_viewers_count == 0:
            viewers_field = MessageEmbedField()
            viewers_field.name = 'Viewers'
            viewers_field.value = str(self.stream_viewers_count)
            viewers_field.inline = True
            e.fields.append(viewers_field)

        return e
示例#3
0
文件: base.py 项目: Ryonez/mee6
    def embed(self):
        e = MessageEmbed()
        e.color = self.color
        e.title = self.stream_title
        e.url = self.stream_url

        author = MessageEmbedAuthor()
        author.name = self.display_name
        author.url = self.stream_url
        author.icon_url = self.avatar
        e.author = author

        thumbnail = MessageEmbedThumbnail()
        thumbnail.url = self.avatar
        thumbnail.proxy_url = self.avatar
        thumbnail.width, thumbnail.height = 100, 100
        e.thumbnail = thumbnail

        image = MessageEmbedImage()
        image.url = self.stream_preview + '?rand={}'.format(randint(0, 999999))
        e.image = image

        footer = MessageEmbedFooter()
        footer.text = self.platform_name
        e.footer = footer

        if self.stream_game:
            game_field = MessageEmbedField()
            game_field.name = 'Played Game'
            game_field.value = self.stream_game
            game_field.inline = True
            e.fields.append(game_field)

        if self.stream_viewers_count or self.stream_viewers_count == 0:
            viewers_field = MessageEmbedField()
            viewers_field.name = 'Viewers'
            viewers_field.value = str(self.stream_viewers_count)
            viewers_field.inline = True
            e.fields.append(viewers_field)

        return e