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

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

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

            var channel = await _mobcrushManager.GetMobcrushIdByName(channelName);

            if (channel == null || channel.Users.Count == 0)
            {
                await Context.Channel.SendMessageAsync(channelName + " doesn't exist on Mobcrush.");

                return;
            }

            var broadcast = await _mobcrushManager.GetMobcrushBroadcastByChannelId(channel.Channel.Id);

            var user = await _mobcrushManager.GetMobcrushStreamById(broadcast.User.Id);

            if (!broadcast.IsLive)
            {
                await Context.Channel.SendMessageAsync(channelName + " isn't currently live on Mobcrush.");

                return;
            }

            if (broadcast.IsLive)
            {
                string gameName     = broadcast.Game == null ? "a game" : broadcast.Game.Name;
                string url          = "http://mobcrush.com/" + channelName;
                string avatarUrl    = user.ProfileLogo == null ? "http://cdn.mobcrush.com/static/images/default-profile-pic.png" : user.ProfileLogo;
                string thumbnailUrl = "http://cdn.mobcrush.com/u/video/" + broadcast.Id + "/snapshot.jpg";

                var message = await _messagingService.BuildMessage(channelName, gameName, "",
                                                                   url, avatarUrl, thumbnailUrl, Constants.Mobcrush, channelName, server, server.GoLiveChannel, null);

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

            var file   = _botSettings.DirectorySettings.ConfigRootDirectory + _botSettings.DirectorySettings.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 _messagingService.BuildMessage(name, stream.game, stream.channel.status, url, avatarUrl,
                                                               thumbnailUrl, Constants.Twitch, stream.channel._id.ToString(), server, server.GoLiveChannel, null);

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

            var file   = _botSettings.DirectorySettings.ConfigRootDirectory + _botSettings.DirectorySettings.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 _messagingService.BuildMessage(stream.token, gameName, stream.name, url,
                                                                   avatarUrl, thumbnailUrl, Constants.Mixer, channelId, server, server.GoLiveChannel, null);

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

            var file   = _botSettings.DirectorySettings.ConfigRootDirectory + _botSettings.DirectorySettings.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 _messagingService.BuildMessage(channelName, gameName, stream.livestream[0].media_status,
                                                                   url, avatarUrl, thumbnailUrl, Constants.Smashcast, channelName, server, server.GoLiveChannel, null);

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

            var file   = _botSettings.DirectorySettings.ConfigRootDirectory + _botSettings.DirectorySettings.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 _messagingService.BuildMessage(channelTitle, "a game", video.snippet.title, url, avatarUrl, thumbnailUrl,
                                                               Constants.YouTubeGaming, video.snippet.channelId, server, server.GoLiveChannel, null);

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