Пример #1
0
        // void	Cmd_ExecuteString (char *text, cmd_source_t src);
        // Parses a single line of text into arguments and tries to execute it.
        // The text can come from the command buffer, a remote client, or stdin.
        //
        // A complete command line has been parsed, so try to execute it
        // FIXME: lookupnoadd the token to speed search?
        public Boolean ExecuteString(String text, CommandSource source)
        {
            var handled = false;

            var msg = CommandMessage.FromString(text, source);

            // execute the command line
            if (msg == null)
            {
                return(handled);
            }

            if (Contains(msg.Name))
            {
                var handler = Get(msg.Name);
                handler?.Invoke(msg);
                handled = true;
            }
            else
            {
                if (ContainsAlias(msg.Name))
                {
                    Buffer.Insert(Aliases[msg.Name]);
                }
                else
                {
                    if (!Cvars.HandleCommand(msg))
                    {
                        ConsoleWrapper.Print($"Unknown command \"{msg.Name}\"\n");
                    }
                }
            }

            return(handled);
        }
Пример #2
0
 internal void ShutdownTask()
 {
     ConfigInstance.Save();
     QuotesInstance.Dispose();
     IntervalMessagesInstance.Dispose();
     ChatFiltering.Dispose();
     Cvars.Dispose();
     SuiBotInstance.LeaveChannel(Channel);
 }
Пример #3
0
        public Host(MainWindow window)
        {
            this.MainWindow = window;
            this.Cvars      = new();

            // Factories
            this.Commands = this.AddFactory <CommandFactory>( );
            this.CVars    = this.AddFactory <ClientVariableFactory>( );

            this.Commands.Initialise(this.CVars);

            // Old
            this.Cache = new();
            //CommandBuffer = new CommandBuffer( this );
            //Command = new Command( this );
            //CVar.Initialise( Command );
            this.View            = new(this);
            this.ChaseView       = new(this);
            this.GfxWad          = new();
            this.Keyboard        = new(this);
            this.Console         = new(this);
            this.Menu            = new(this);
            this.Programs        = new(this);
            this.ProgramsBuiltIn = new(this);
            this.Model           = new(this);
            this.Network         = new(this);
            this.Server          = new(this);
            this.Client          = new(this);
            this.Video           = new(this);
            this.DrawingContext  = new(this);
            this.Screen          = new(this);
            this.RenderContext   = new(this);
            this.Sound           = new(this);
            this.CDAudio         = new(this);
            this.Hud             = new(this);
            this.DedicatedServer = new();

            this.WadFiles    = new();
            this.WadTextures = new();
        }
Пример #4
0
        public Host(MainWindow window)
        {
            MainWindow = window;
            Cvars      = new Cvars();

            // Factories
            Commands = AddFactory <CommandFactory>( );
            CVars    = AddFactory <ClientVariableFactory>( );

            Commands.Initialise(CVars);

            // Old
            Cache = new Cache( );
            //CommandBuffer = new CommandBuffer( this );
            //Command = new Command( this );
            //CVar.Initialise( Command );
            View            = new View(this);
            ChaseView       = new ChaseView(this);
            GfxWad          = new Wad( );
            Keyboard        = new Keyboard(this);
            Console         = new Con(this);
            Menu            = new Menu(this);
            Programs        = new Programs(this);
            ProgramsBuiltIn = new ProgramsBuiltIn(this);
            Model           = new Mod(this);
            Network         = new Network(this);
            Server          = new server(this);
            Client          = new client(this);
            Video           = new Vid(this);
            DrawingContext  = new Drawer(this);
            Screen          = new Scr(this);
            RenderContext   = new render(this);
            Sound           = new snd(this);
            CDAudio         = new cd_audio(this);
            Hud             = new Hud(this);
            DedicatedServer = new DedicatedServer( );

            WadFiles    = new Dictionary <String, Wad>( );
            WadTextures = new Dictionary <String, String>( );
        }
Пример #5
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;
                }
            }
        }