Example #1
0
            /// <summary>
            /// Does the work for changing the profile name
            /// </summary>
            private void profileChangeWorker_DoWork(object sender, DoWorkEventArgs e)
            {
                try
                {
                    Profile newProfile = null;
                    if (e.Argument is string)
                    {
                        newProfile      = new Profile();
                        newProfile.Name = e.Argument as string;
                    }
                    else if (e.Argument is Profile)
                    {
                        newProfile = e.Argument as Profile;
                    }
                    else
                    {
                        throw new ArgumentException(@"Unrecognized type. Don't know what to do.", "e.Argument");
                    }

                    StreamViewer.SetProfileOnServer(newProfile);
                }
                catch (Exception ex)
                {
                    e.Result = ex;
                }
            }
 void RewardForViewing()
 {
     if (((TimeSpan)(DateTime.Now - LastViewerRewardCheck)).TotalSeconds < 60) { return; }
     LastViewerRewardCheck = DateTime.Now;
     if (!Data.APIIntergrations.Twitch.IsLive(BotInstance)) { return; }
     Newtonsoft.Json.Linq.JToken JData = Data.APIIntergrations.Twitch.GetViewers(BotInstance);
     int Reward = int.Parse(BotInstance.CommandConfig["AutoRewards"]["Viewing"]["RewardPerMinute"].ToString());
     IEnumerable<Newtonsoft.Json.Linq.JToken> Merged = JData["chatters"]["vips"].
         Union(JData["chatters"]["moderators"]).
         Union(JData["chatters"]["staff"]).
         Union(JData["chatters"]["admins"]).
         Union(JData["chatters"]["global_mods"]).
         Union(JData["chatters"]["viewers"]);
     List<KeyValuePair<string, string>> Headers;
     Headers = new List<KeyValuePair<string, string>> {
         new KeyValuePair<string, string>("BalanceIncrement",Reward.ToString()),
         new KeyValuePair<string, string>("WatchTimeIncrement","1"),
         new KeyValuePair<string, string>("CurrencyID",this.BotInstance.Currency.ID.ToString())
     };
     JData = Newtonsoft.Json.Linq.JToken.Parse("{'TwitchIDs':[]}");
     List<string> TwitchIDs = new List<string> { };
     foreach (Newtonsoft.Json.Linq.JToken StreamViewer in Merged)
     {
         StandardisedUser U = StandardisedUser.FromTwitchUsername(StreamViewer.ToString(), BotInstance);
         if (U != null) { TwitchIDs.Add(U.ID); }
     }
     JData["TwitchIDs"] = Newtonsoft.Json.Linq.JToken.FromObject(TwitchIDs);
     Data.APIIntergrations.RewardCurrencyAPI.WebRequests.PostRequest("viewer", Headers, true,JData);
 }
Example #3
0
        /// <summary>
        /// Add loyaltypoints to user
        /// </summary>
        /// <param name="user">ApplicationUser</param>
        /// <param name="viewer">Viewers currently in channel</param>
        /// <param name="loyaltyPoints">Points to give to the user, or null for periodic channel loyalty</param>
        public void AddLoyalty(ApplicationUser user, string channel, StreamViewer viewer, int?loyaltyPoints = null)
        {
            var viewList = new List <StreamViewer> {
                viewer
            };

            AddLoyalty(user, channel, viewList, loyaltyPoints);
        }
Example #4
0
        /// <summary>
        /// Save gamble DateTime for user, timeout for x minutes
        /// </summary>
        /// <param name="user">ApplicationUser</param>
        /// <param name="channel">string</param>
        /// <param name="streamViewer">StreamViewer</param>
        public void StampLastGamble(ApplicationUser user, string channel, StreamViewer streamViewer)
        {
            Context = new ApplicationDbContext();

            var bcs = GetBotChannelSettings(user);

            var dbViewer = Context.Viewers.SingleOrDefault(s => s.Id == streamViewer.Id && s.Channel.ToLower() == channel.ToLower());

            dbViewer.LastGamble = DateTime.Now;

            Context.SaveChanges();
        }
Example #5
0
        public Stream RemoveViewer(Stream streamInfo, User viewer)
        {
            var stream = _context.Streams
                         .Find(streamInfo.Id)
                         ?? throw new ArgumentException("Stream doesn't exist");

            var streamViewer = new StreamViewer
            {
                Stream = stream,
                Viewer = viewer
            };

            stream.Viewers.Remove(streamViewer);
            viewer.ResolveState(User.UserState.Active);

            _context.SaveChanges();

            return(stream);
        }
Example #6
0
        public IQueryable <Trigger> GetCallableTriggers(ApplicationUser user, StreamViewer chatter, ChatCommand msg)
        {
            var allTriggers = GetTriggers(user);

            return((IQueryable <Trigger>)allTriggers.Where(t => t.CanTrigger(chatter, msg) && t.Active == true));
        }