Esempio n. 1
0
 internal void ShutdownTask()
 {
     ConfigInstance.Save();
     QuotesInstance.Dispose();
     IntervalMessagesInstance.Dispose();
     ChatFiltering.Dispose();
     Cvars.Dispose();
     SuiBotInstance.LeaveChannel(Channel);
 }
Esempio n. 2
0
        internal void DoWork(ChatMessage lastMessage)
        {
            //If Filtering is enabled and timeouted or banned, we don't need to do anything else
            if (ConfigInstance.FilteringEnabled && PerformActionFiltering(lastMessage))
            {
                return;
            }

            //This is a useful optimisation trick, since commands all start with a one and the same prefix, we don't actually have to spend time comparing strings, if we know that prefix was wrong
            if (!lastMessage.Message.StartsWith(CommandPrefix) || CoreConfigInstance.IgnoredUsers.Contains(lastMessage.Username))
            {
                return;
            }

            //Do not perform actions if user is on cooldown
            if (UserCooldowns.ContainsKey(lastMessage.Username) && UserCooldowns[lastMessage.Username] > DateTime.UtcNow)
            {
                return;
            }

            //All of the commands are declared with lower cases
            var messageLazy = lastMessage.Message.ToLower();

            messageLazy = messageLazy.Remove(0, 1);

            //Properties
            if (messageLazy.StartsWithLazy("getproperty"))
            {
                ConfigInstance.GetProperty(this, lastMessage);
                return;
            }

            if (messageLazy.StartsWithLazy("setproperty"))
            {
                ConfigInstance.SetPropety(this, lastMessage);
                return;
            }

            //Quotes
            if (ConfigInstance.QuotesEnabled && (messageLazy.StartsWith("quote") || messageLazy.StartsWith("quotes")))
            {
                QuotesInstance.DoWork(lastMessage);
                return;
            }

            //Chat Filter
            if (ConfigInstance.FilteringEnabled && (messageLazy.StartsWith("chatfilter") || messageLazy.StartsWith("filter")))
            {
                ChatFiltering.DoWork(lastMessage);
                return;
            }

            //Leaderboards
            if (ConfigInstance.LeaderboardsEnabled)
            {
                if (messageLazy == "wr" || messageLazy.StartsWithWordLazy("wr"))
                {
                    Leaderboards.DoWorkWR(lastMessage);
                    return;
                }
                else if (messageLazy == "pb" || messageLazy.StartsWithWordLazy("pb"))
                {
                    Leaderboards.DoWorkPB(lastMessage);
                    return;
                }
                else if (lastMessage.UserRole <= Role.Mod && messageLazy.StartsWithWordLazy(new string[] { "leaderboard", "leaderboards" }))
                {
                    Leaderboards.DoModWork(lastMessage);
                    return;
                }
            }

            //Interval Messages
            if (ConfigInstance.IntervalMessageEnabled)
            {
                if (messageLazy.StartsWithWordLazy(new string[] { "intervalmessage", "intervalmessages" }))
                {
                    if (lastMessage.UserRole <= Role.Mod)
                    {
                        IntervalMessagesInstance.DoWork(lastMessage);
                        return;
                    }
                    else
                    {
                        return;
                    }
                }
            }

            //Srl
            if (messageLazy.StartsWith("srl"))
            {
                Components.SRL.GetRaces(this);
                SetUserCooldown(lastMessage, DefaultCooldown);
                return;
            }

            //PCGW
            if (messageLazy.StartsWith("pcgw"))
            {
                PCGW.DoWork(lastMessage);
                return;
            }

            //Twitch update
            if (messageLazy.StartsWith("updatestatus") && lastMessage.UserRole <= Role.VIP)
            {
                UpdateTwitchStatus(true);
                return;
            }

            //Killswitch
            if (messageLazy.StartsWith("killbot") && lastMessage.UserRole == Role.SuperMod)
            {
                ShutdownTask();
                return;
            }

            //GenericUtilComponents
            if (ConfigInstance.GenericUtil.ENABLE)
            {
                if (ConfigInstance.GenericUtil.UptimeEnabled && messageLazy.StartsWith("uptime"))
                {
                    GenericUtil.GetUpTime(lastMessage);
                    return;
                }
            }


            //MemeCompoenents
            if (ConfigInstance.MemeComponents.ENABLE)
            {
                MemeComponents.DoWork(lastMessage);
            }


            //Custom Cvars
            if (ConfigInstance.CustomCvarsEnabled)
            {
                if (messageLazy.StartsWithLazy(new string[] { "cvar", "cvars" }))
                {
                    if (lastMessage.UserRole <= Role.Mod)
                    {
                        Cvars.DoWork(lastMessage);
                        return;
                    }
                    else
                    {
                        return;
                    }
                }

                if (Cvars.PerformCustomCvar(lastMessage))
                {
                    return;
                }
            }
        }