Esempio n. 1
0
        public async Task <ActionResult> GetPlaylist(string channel)
        {
            var model = new List <PlayListItem>();

            ViewBag.channel = channel;
            try
            {
                var user = ContextService.GetUserFromChannelname(channel);
                var bcs  = ContextService.GetBotChannelSettings(user);
                var bus  = ContextService.GetBotUserSettingsForUser(user);

                var channelMeta = await Api.V5.Channels.GetChannelAsync(bus.ChannelToken);

                ViewBag.ChannelProfileBannerUrl = channelMeta.ProfileBanner;
                ViewBag.ChannelLogo             = channelMeta.Logo;
                var songRequests   = bcs.SongRequests.Where(s => s.Deleted == false);
                var songThumbnails = new List <string>();
                var client         = new YoutubeClient();
                foreach (var song in songRequests)
                {
                    var video = await client.GetVideoAsync(song.VideoId);

                    songThumbnails.Add(video.Thumbnails.LowResUrl);
                }

                ViewBag.Thumbnails = songThumbnails;
                return(View(songRequests));
            }
            catch (Exception e)
            {
                ViewBag.Error = e.Message;
                return(View(model));
            }
        }
Esempio n. 2
0
        public ActionResult Loyalty()
        {
            var botChannelSettings = ContextService.GetBotChannelSettings(ContextService.GetUser(User.Identity.Name));

            if (botChannelSettings.Loyalty != null)
            {
                return(Json(JsonConvert.SerializeObject(botChannelSettings.Loyalty)));
            }
            else
            {
                var loyalty = new Loyalty();
                return(Json(JsonConvert.SerializeObject(loyalty)));
            }
        }
Esempio n. 3
0
        public ActionResult KillStatAjax(string channel)
        {
            ViewBag.channel = channel;
            var killStats = new KillStat();

            try
            {
                var user = ContextService.GetUserFromChannelname(channel);
                var bcs  = ContextService.GetBotChannelSettings(user);
                return(Json(new { kills = bcs.KillStats.Kills, deaths = bcs.KillStats.Deaths, squad = bcs.KillStats.SquadKills }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                ViewBag.Error = e.Message;
                return(Json(new { kills = killStats.Kills, deaths = killStats.Deaths, squad = killStats.SquadKills }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 4
0
        public ActionResult KillStat(string channel, bool?dark = false)
        {
            ViewBag.channel = channel;
            ViewBag.DarkCss = dark;
            var killStats = new KillStat();

            try
            {
                var user = ContextService.GetUserFromChannelname(channel);
                var bcs  = ContextService.GetBotChannelSettings(user);
                return(View(bcs.KillStats));
            }
            catch (Exception e)
            {
                ViewBag.Error = e.Message;
                return(View(killStats));
            }
        }
Esempio n. 5
0
        public ActionResult Index()
        {
            // get users bot settings
            var userBotSettings = ContextService.GetBotUserSettingsForUser(ContextService.GetUser(User.Identity.Name));
            var userLoyalty     = ContextService.GetBotChannelSettings(ContextService.GetUser(User.Identity.Name)).Loyalty;
            var timers          = ContextService.GetTimers(ContextService.GetUser(User.Identity.Name));
            var triggers        = ContextService.GetTriggers(ContextService.GetUser(User.Identity.Name));
            var bannedWords     = ContextService.GetBotChannelSettings(ContextService.GetUser(User.Identity.Name))
                                  .BannedWords;

            if (bannedWords == null)
            {
                bannedWords = new List <BannedWord>();
            }
            var stringBannedWords = new List <string>();

            foreach (var bannedWord in bannedWords)
            {
                stringBannedWords.Add(bannedWord.Word);
            }

            var loyalty            = userLoyalty ?? new Loyalty();
            var dashboardViewModel = new DashboardViewModel()
            {
                BotUserSettings = userBotSettings,
                LoyaltySettings = loyalty,
                Timers          = timers,
                Triggers        = triggers,
                BannedWords     = string.Join(",", stringBannedWords)
            };

            // send user to bot preferences page if not set
            if (string.IsNullOrWhiteSpace(userBotSettings.BotChannel) || string.IsNullOrWhiteSpace(userBotSettings.BotUsername) ||
                string.IsNullOrWhiteSpace(userBotSettings.BotUsername))
            {
                RedirectToAction("Preferences", new { message = "Please set your bot account and channel information" });
            }

            // assert that
            return(View(dashboardViewModel));
        }