Beispiel #1
0
        public async Task Announce(string channelName)
        {
            if (!IsAdmin)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            var twitchId = await _twitchManager.GetTwitchIdByLogin(channelName);

            if (!string.IsNullOrEmpty(twitchId) && twitchId == "0")
            {
                await Context.Channel.SendMessageAsync(channelName + " doesn't exist on Twitch.");

                return;
            }

            var streamResponse = await _twitchManager.GetStreamById(twitchId);

            var stream = streamResponse.stream;

            if (stream == null)
            {
                await Context.Channel.SendMessageAsync(channelName + " isn't online.");

                return;
            }

            string url          = stream.channel.url;
            string name         = StringUtilities.ScrubChatMessage(stream.channel.display_name);
            string avatarUrl    = stream.channel.logo != null ? stream.channel.logo : "https://static-cdn.jtvnw.net/jtv_user_pictures/xarth/404_user_70x70.png";
            string thumbnailUrl = stream.preview.large;

            var message = await MessagingHelper.BuildMessage(name, stream.game, stream.channel.status, url, avatarUrl,
                                                             thumbnailUrl, Constants.Twitch, stream.channel._id.ToString(), server, server.GoLiveChannel, null);

            await MessagingHelper.SendMessages(Constants.Twitch, new List <BroadcastMessage>() { message });
        }
Beispiel #2
0
        public async Task Announce(string channelName)
        {
            if (!IsAdmin)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            var stream = await _mixerManager.GetChannelByName(channelName);

            if (stream == null)
            {
                await Context.Channel.SendMessageAsync(channelName + " doesn't exist on Mixer.");

                return;
            }

            if (stream.online)
            {
                string gameName     = stream.type == null ? "a game" : stream.type.name;
                string url          = "http://mixer.com/" + stream.token;
                string avatarUrl    = stream.user.avatarUrl != null ? stream.user.avatarUrl : "https://mixer.com/_latest/assets/images/main/avatars/default.jpg";
                string thumbnailUrl = "https://thumbs.mixer.com/channel/" + stream.id + ".small.jpg";
                string channelId    = stream.id.Value.ToString();

                var message = await MessagingHelper.BuildMessage(stream.token, gameName, stream.name, url,
                                                                 avatarUrl, thumbnailUrl, Constants.Mixer, channelId, server, server.GoLiveChannel);

                await MessagingHelper.SendMessages(Constants.Mixer, new List <BroadcastMessage>() { message });
            }
            else
            {
                await Context.Channel.SendMessageAsync(channelName + " is offline.");
            }
        }
Beispiel #3
0
        public async Task Announce(string channelName)
        {
            if (!IsAdmin)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            var stream = await _smashcastManager.GetChannelByName(channelName);

            if (stream == null)
            {
                await Context.Channel.SendMessageAsync(channelName + " doesn't exist on Smashcast.");

                return;
            }

            if (stream.livestream[0].media_is_live == "1")
            {
                string gameName     = stream.livestream[0].category_name == null ? "a game" : stream.livestream[0].category_name;
                string url          = "http://smashcast.tv/" + channelName;
                string avatarUrl    = "http://edge.sf.hitbox.tv" + stream.livestream[0].channel.user_logo;
                string thumbnailUrl = "http://edge.sf.hitbox.tv" + stream.livestream[0].media_thumbnail_large;

                var message = await MessagingHelper.BuildMessage(channelName, gameName, stream.livestream[0].media_status,
                                                                 url, avatarUrl, thumbnailUrl, Constants.Smashcast, channelName, server, server.GoLiveChannel, null);

                await MessagingHelper.SendMessages(Constants.Smashcast, new List <BroadcastMessage>() { message });
            }
            else
            {
                await Context.Channel.SendMessageAsync(channelName + " is offline.");
            }
        }
Beispiel #4
0
        public async Task Announce(string videoId)
        {
            if (!IsAdmin)
            {
                return;
            }

            var file   = Constants.ConfigRootDirectory + Constants.GuildDirectory + Context.Guild.Id + ".json";
            var server = new DiscordServer();

            if (File.Exists(file))
            {
                server = JsonConvert.DeserializeObject <DiscordServer>(File.ReadAllText(file));
            }

            var videoResponse = await _youTubeManager.GetVideoById(videoId);

            if (videoResponse == null || videoResponse.items == null || videoResponse.items.Count == 0)
            {
                await Context.Channel.SendMessageAsync("A video with the ID " + videoId + " doesn't exist on YouTube.");

                return;
            }

            var video       = videoResponse.items[0];
            var channelData = await _youTubeManager.GetYouTubeChannelSnippetById(video.snippet.channelId);

            string url          = "http://" + (server.UseYouTubeGamingPublished ? "gaming" : "www") + ".youtube.com/watch?v=" + videoId;
            string channelTitle = video.snippet.channelTitle;
            string avatarUrl    = channelData.items.Count > 0 ? channelData.items[0].snippet.thumbnails.high.url : "";
            string thumbnailUrl = video.snippet.thumbnails.high.url;

            var message = await MessagingHelper.BuildMessage(channelTitle, "a game", video.snippet.title, url, avatarUrl, thumbnailUrl,
                                                             Constants.YouTubeGaming, video.snippet.channelId, server, server.GoLiveChannel);

            await MessagingHelper.SendMessages(Constants.YouTube, new List <BroadcastMessage>() { message });
        }