def announce_hitbox(self, guild, stream): stream_id = stream['media_id'] check = guild.storage.sismember('announced_hitbox_streams', stream_id) if check: return channel = stream['channel'] embed = MessageEmbed() embed.color = 0x99cc00 embed.title = stream['media_status'] embed.url = channel['channel_link'] embed.author_name = stream['media_display_name'] embed.author_icon_url = 'https://edge.sf.hitbox.tv' + channel[ 'user_logo'] embed.author_url = channel['channel_link'] embed.thumbnail_url = 'https://edge.sf.hitbox.tv' + channel['user_logo'] embed.thumbnail_proxy_url = 'https://edge.sf.hitbox.tv' + channel[ 'user_logo'] embed.thumbnail_width, embed.thumbnail_height = 100, 100 embed.image_url = 'https://edge.sf.hitbox.tv' + stream[ 'media_thumbnail'] embed.footer_text = 'Hitbox.tv' game = stream.get('category_name', "") if game: embed.add_field('Played Game', game, True) embed.add_field('Viewers', stream['category_viewers'] or 0, True) message = guild.config['announcement_message'] message = message.replace('{streamer}', embed.author_name) message = message.replace('{link}', embed.url) self.log('[Hitbox] Announcing {} to {}'.format(embed.author_name, guild.id)) try: send_message(guild.config['announcement_channel'], message, embed=embed) guild.storage.sadd('announced_hitbox_streams', stream_id) except APIException as e: self.log('[Hitbox] An error occured {} {} {}'.format( e.status_code, e.error_code, e.payload)) if e.status_code in (403, 404): self.log('[Hitbox] Disabling plugin for {}'.format(guild.id)) self.disable(guild)
def announce_twitch(self, guild, stream): stream_id = stream['_id'] check = guild.storage.sismember('announced_twitch_streams', stream_id) if check: return channel = stream['channel'] embed = MessageEmbed() embed.color = 0x6441A4 embed.title = channel['status'] embed.url = channel['url'] embed.author_name = channel['display_name'] embed.author_icon_url = channel['logo'] embed.author_url = channel['url'] embed.thumbnail_url = channel['logo'] embed.thumbnail_proxy_url = channel['logo'] embed.thumbnail_width, embed.thumbnail_height = 100, 100 embed.image_url = stream['preview']['medium'] embed.footer_text = 'Twitch.tv' game = stream.get('game') if game: embed.add_field('Played Game', game, True) embed.add_field('Viewers', stream['viewers'], True) message = guild.config['announcement_message'] message = message.replace('{streamer}', embed.author_name) message = message.replace('{link}', embed.url) self.log('[Twitch] Announcing {} to {}'.format(embed.author_name, guild.id)) try: send_message(guild.config['announcement_channel'], message, embed=embed) guild.storage.sadd('announced_twitch_streams', stream_id) except APIException as e: self.log('[Twitch] An error occured {} {} {}'.format( e.status_code, e.error_code, e.payload)) if e.status_code in (403, 404): self.log('[Twitch] Disabling plugin for {}'.format(guild.id)) self.disable(guild)
def send(self, guild, channel): guild_id = get(guild, 'id', guild) channel_id = get(channel, 'id', channel) return send_message(channel_id, self.message, embed=self.embed)