コード例 #1
0
            public bool contains(ref string listname, string key, ListFlags flags = ListFlags.Unchanged)
            {
                try
                {
                    StringListManager list = OpenList(listname);
                    return(list.Contains(key));
                }
                catch (Exception ex) { Plugin.Log(ex.ToString()); } // Going to try this form, to reduce code verbosity.

                return(false);
            }
コード例 #2
0
        private string ProcessSongRequest(ParseState state)
        {
            try
            {
                if (RequestBotConfig.Instance.RequestQueueOpen == false && !state.flags.HasFlag(CmdFlags.NoFilter) && !state.flags.HasFlag(CmdFlags.Local)) // BUG: Complex permission, Queue state message needs to be handled higher up
                {
                    QueueChatMessage($"Queue is currently closed.");
                    return(success);
                }

                if (!RequestTracker.ContainsKey(state.user.Id))
                {
                    RequestTracker.Add(state.user.Id, new RequestUserTracker());
                }

                int limit = RequestBotConfig.Instance.UserRequestLimit;
                if (state.user.IsSubscriber)
                {
                    limit = Math.Max(limit, RequestBotConfig.Instance.SubRequestLimit);
                }
                if (state.user.IsModerator)
                {
                    limit = Math.Max(limit, RequestBotConfig.Instance.ModRequestLimit);
                }
                if (state.user.IsVip)
                {
                    limit += RequestBotConfig.Instance.VipBonusRequests;                   // Current idea is to give VIP's a bonus over their base subscription class, you can set this to 0 if you like
                }
                if (!state.user.IsBroadcaster)
                {
                    if (RequestTracker[state.user.Id].numRequests >= limit)
                    {
                        if (RequestBotConfig.Instance.LimitUserRequestsToSession)
                        {
                            new DynamicText().Add("Requests", RequestTracker[state.user.Id].numRequests.ToString()).Add("RequestLimit", RequestBotConfig.Instance.SubRequestLimit.ToString()).QueueMessage("You've already used %Requests% requests this stream. Subscribers are limited to %RequestLimit%.");
                        }
                        else
                        {
                            new DynamicText().Add("Requests", RequestTracker[state.user.Id].numRequests.ToString()).Add("RequestLimit", RequestBotConfig.Instance.SubRequestLimit.ToString()).QueueMessage("You already have %Requests% on the queue. You can add another once one is played. Subscribers are limited to %RequestLimit%.");
                        }

                        return(success);
                    }
                }

                if (automtt.Contains(state.user.UserName.ToLower()))
                {
                    QueueChatMessage($"{state.user.DisplayName}'s request was promoted!");
                    state.flags |= CmdFlags.MoveToTop;
                    state.flags |= CmdFlags.Mod;
                    automtt.Removeentry(state.user.UserName.ToLower());
                    state.info = "!promoted";
                }

                // BUG: Need to clean up the new request pipeline
                string testrequest = normalize.RemoveSymbols(ref state.parameter, normalize._SymbolsNoDash);

                RequestInfo newRequest = new RequestInfo(state.user, state.parameter, DateTime.UtcNow, _digitRegex.IsMatch(testrequest) || _beatSaverRegex.IsMatch(testrequest), state, state.flags, state.info);

                if (!newRequest.isBeatSaverId && state.parameter.Length < 2)
                {
                    QueueChatMessage($"Request \"{state.parameter}\" is too short- Beat Saver searches must be at least 3 characters!");
                }
                if (!UnverifiedRequestQueue.Contains(newRequest))
                {
                    UnverifiedRequestQueue.Enqueue(newRequest);
                }
            }
            catch (Exception ex)
            {
                Plugin.Log(ex.ToString());
            }
            return(success);
        }