Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            TwitchChatBot chatBot = new TwitchChatBot();

            chatBot.Connect();

            string quitmsg    = "exit";
            string helpmsg    = "Help";
            string comparemsg = string.Empty;

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine(string.Format("Type '{0}' to close the bot", quitmsg));
            Console.WriteLine(string.Format("Type '{0}' for additional commands", helpmsg));
            Console.WriteLine("Alternatively, you may use this command line to chat as the bot.");
            Console.ResetColor();

            while (true)
            {
                comparemsg = Console.ReadLine();
                if (!Convert.ToBoolean(string.Compare(quitmsg, comparemsg, true))) // string.compare returns 0 for exact match
                {
                    break;
                }

                if (ConsoleCommands.CallCommand(comparemsg) == false)
                {
                    chatBot.SendMessage(comparemsg);
                }
            }
            chatBot.Disconnect();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts the server.
        /// </summary>
        public override void Run()
        {
            base.Run();

            CliUtil.WriteHeader("Web", ConsoleColor.DarkRed);
            CliUtil.LoadingTitle();

            // Conf
            this.LoadConf(this.Conf = new Conf());

            // Database
            this.InitDatabase(this.Database = new MeliaDb(), this.Conf);

            // Data
            this.LoadData(DataToLoad.Servers, true);

            // Web server
            this.StartWebServer();

            CliUtil.RunningTitle();

            // Commands
            this.ConsoleCommands = new ConsoleCommands();
            this.ConsoleCommands.Wait();
        }
Ejemplo n.º 3
0
        public McGame()
        {
            Gdm = new GraphicsDeviceManager(this)
            {
                PreferredBackBufferHeight = GameConts.Height * GameConts.Instance.Scale,
                PreferredBackBufferWidth  = GameConts.Width * GameConts.Instance.Scale
            };

            Cc = new ConsoleCommands(this);

            Console = new ConsoleComponent(this)
            {
                Interpreter = Cc.ManualInterpreter
            };
            FpsCounterComponent = new FpsCounterComponent(this);

            Components.Add(Console);
            Components.Add(FpsCounterComponent);

            IsMouseVisible        = true;
            Content.RootDirectory = "Content";

            Window.Title = $"{GameConts.Name} :: {GameConts.Version}";

            GameConts.Instance.Load();

            Window.IsBorderless = GameConts.Instance.Borderless;
            Gdm.IsFullScreen    = GameConts.Instance.FullScreen;

            IsFixedTimeStep = false;
            Gdm.SynchronizeWithVerticalRetrace = true;
            Gdm.ApplyChanges();
        }
Ejemplo n.º 4
0
    /// <inheritdoc />
    public override void Entry(IModHelper helper)
    {
        I18n.Init(helper.Translation);
        Globals.Initialize(helper, this.Monitor, this.ModManifest);

        ConsoleCommands.Register(this.Helper.ConsoleCommands);

        // Register events
        helper.Events.GameLoop.GameLaunched    += this.OnGameLaunched;
        helper.Events.GameLoop.TimeChanged     += this.OnTimeChanged;
        helper.Events.GameLoop.DayEnding       += this.OnDayEnding;
        helper.Events.GameLoop.ReturnedToTitle += this.ReturnedToTitle;
        helper.Events.GameLoop.SaveLoaded      += this.OnSaveLoaded;
        helper.Events.Input.ButtonPressed      += this.OnButtonPressed;
        helper.Events.Player.Warped            += this.OnPlayerWarped;

        helper.Events.Multiplayer.PeerConnected      += this.PeerConnected;
        helper.Events.Multiplayer.ModMessageReceived += this.ModMessageReceived;

        // Add my asset loader and editor.
        helper.Content.AssetLoaders.Add(AssetLoader.Instance);
        helper.Content.AssetEditors.Add(AssetEditor.Instance);

        this.ApplyPatches(new Harmony(this.ModManifest.UniqueID));
    }
Ejemplo n.º 5
0
        public static void Main(string[] Args)
        {
            DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_CLOSE, MF_BYCOMMAND);

            XmlConfigurator.Configure();

            Console.ForegroundColor = ConsoleColor.White;
            Console.CursorVisible   = false;
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += MyHandler;

            PlusEnvironment.Initialize();

            while (true)
            {
                if (Console.ReadKey(true).Key == ConsoleKey.Enter)
                {
                    Console.Write("plus> ");
                    string Input = Console.ReadLine();

                    if (Input.Length > 0)
                    {
                        string s = Input.Split(' ')[0];

                        ConsoleCommands.InvokeCommand(s);
                    }
                }
            }
        }
Ejemplo n.º 6
0
		public void Run()
		{
			if (_running)
				throw new Exception("Server is already running.");
			_running = true;

			CliUtil.WriteHeader("Msgr Server", ConsoleColor.DarkCyan);
			CliUtil.LoadingTitle();

			this.NavigateToRoot();

			// Conf
			this.LoadConf(this.Conf = new MsgrConf());

			// Database
			this.InitDatabase(this.Database = new MsgrDb(), this.Conf);

			// Start
			this.Server.Start(this.Conf.Msgr.Port);

			CliUtil.RunningTitle();

			var cmd = new ConsoleCommands();
			cmd.Wait();
		}
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), ScClose, MfBycommand);

            XmlConfigurator.Configure();

            Console.ForegroundColor = ConsoleColor.White;
            Console.CursorVisible   = false;

            var currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += PlusEnvironment.MyHandler;

            PlusEnvironment.Initialize();

            while (true)
            {
                if (Console.ReadKey(true).Key != ConsoleKey.Enter)
                {
                    continue;
                }

                Console.Write("plus> ");
                var input = Console.ReadLine();

                if (input == null || input.Length <= 0)
                {
                    continue;
                }

                var s = input.Split(' ')[0];
                ConsoleCommands.InvokeCommand(s);
            }
        }
Ejemplo n.º 8
0
        public void Run()
        {
            if (_running)
            {
                throw new Exception("Server is already running.");
            }
            _running = true;

            CliUtil.WriteHeader("Msgr Server", ConsoleColor.DarkCyan);
            CliUtil.LoadingTitle();

            this.NavigateToRoot();

            // Conf
            this.LoadConf(this.Conf = new MsgrConf());

            // Database
            this.InitDatabase(this.Database = new MsgrDb(), this.Conf);

            // Start
            this.Server.Start(this.Conf.Msgr.Port);

            CliUtil.RunningTitle();

            var cmd = new ConsoleCommands();

            cmd.Wait();
        }
 public static void UncutEquipment()
 {
     DebugConsole.Log("RAIN UNCUT EQUIPMENT!");
     ConsoleCommands.SpawnLootItem("AmbassadorGreatsword");
     ConsoleCommands.SpawnLootItem("GreatswordTuln");
     ConsoleCommands.SpawnLootItem("SkullHammer");
     ConsoleCommands.SpawnLootItem("HealingHam");
     ConsoleCommands.SpawnLootItem("MaxwellHammer");
     ConsoleCommands.SpawnLootItem("ThunderHammer");
     ConsoleCommands.SpawnLootItem("SwordOfAli");
     ConsoleCommands.SpawnLootItem("AbraxisWand");
     ConsoleCommands.SpawnLootItem("BaseShield2");
     ConsoleCommands.SpawnLootItem("BerelaineShield");
     ConsoleCommands.SpawnLootItem("StaffOfPoints");
     ConsoleCommands.SpawnLootItem("GoldBuckler");
     ConsoleCommands.SpawnLootItem("Stilletto");
     ConsoleCommands.SpawnLootItem("ProngedHilt");
     ConsoleCommands.SpawnLootItem("ProngedBlade");
     ConsoleCommands.SpawnLootItem("IntricateShield");
     ConsoleCommands.SpawnLootItem("UnreliableBuckler");
     ConsoleCommands.SpawnLootItem("LargeWoodenShield");
     ConsoleCommands.SpawnLootItem("ShellMaceHammer");
     ConsoleCommands.SpawnLootItem("ThermiasBlade");
     ConsoleCommands.SpawnLootItem("WingedBlade");
     ConsoleCommands.SpawnLootItem("SpectralShiv");
     ConsoleCommands.SpawnLootItem("VikingAxe");
 }
Ejemplo n.º 10
0
        private static void Main(string[] args)
        {
            // For this demo I've written ExchangeRatesApi class, which provides several methods
            // representing requests to https://exchangeratesapi.io/.
            // These return various forex currency rates at the given day.
            // So let's allow user to call them from console via text input,
            // passing function parameters as JSON objects:

            // First, create instance containing several commands which call ExchangeRates API synchronously.
            var exchangeRatesApi = new ExchangeRatesApi();

            // Customize 'command result to string' converter a bit for better output printing,
            // since exchangeratesapi.io returns ISO dates without time part.
            var commandReturnsConverter = new CommandReturnedObjectJsonConverter(true, Formatting.Indented,
                                                                                 new JsonSerializerSettings {
                DateFormatString = "yyyy'-'MM'-'dd"
            });

            // Create command manager. It will contain a set of commands, parse given user input into a proper command,
            // convert its parameters from a string to typed objects, execute the command with converted parameters
            // and return a result.
            var consoleCommands = new ConsoleCommands(ConsoleCommandParser.Default,
                                                      ConsoleCommandParameterConverter.Default);

            // Argument JSON handling can be customized by passing 'new ConsoleCommandParameterConverter(yourJsonDeserializerSettings)' here.

            // Methods marked with [CommandExecutable] will be added from the given exchangeRatesApi instance:
            consoleCommands.RegisterAllFromInstance(exchangeRatesApi);

            // Example of the manually created commands:
            var help = new Func <string>(() => {
                Console.WriteLine($"Available commands:{Environment.NewLine}");
                return(consoleCommands.ToString());
            });

            consoleCommands.Register(new ConsoleCommand(help.Target !, help.Method, "help",
                                                        "Prints available commands.", new[] { "commands" }));

            var clearScreen = new Action(Console.Clear);

            consoleCommands.Register(new ConsoleCommand(clearScreen.Target !, clearScreen.Method, "clear",
                                                        "Clears console.", new[] { "cls" }));

            var quit = new Action(() => Environment.Exit(0));

            consoleCommands.Register(new ConsoleCommand(quit.Target !, quit.Method, "quit",
                                                        "Quits the program.", new[] { "q" }));

            Console.WriteLine("Input \"help\" without quotes to see available commands. Pass command parameters as " +
                              "JSON, for example: d(\"2019-12-31\", \"USD\", [\"EUR\", \"RUB\"])");

            // Continue to execute user imput until the 'quit' command:
            while (true)
            {
                Console.Write("Command prompt: ");
                string commandRepr = Console.ReadLine();
                string evaluated   = consoleCommands.Execute(commandRepr).ConvertOrError(commandReturnsConverter);
                Console.WriteLine(evaluated);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Loads all necessary components and starts the server.
        /// </summary>
        public void Run()
        {
            if (_running)
            {
                throw new Exception("Server is already running.");
            }

            CliUtil.WriteHeader("Web Server", ConsoleColor.DarkRed);
            CliUtil.LoadingTitle();

            this.NavigateToRoot();

            // Conf
            this.LoadConf(this.Conf = new WebConf());

            // Database
            this.InitDatabase(this.Database = new AuraDb(), this.Conf);

            // Localization
            this.LoadLocalization(this.Conf);

            // Server
            this.StartWebServer();

            // Scripts (after web server)
            this.LoadScripts();

            CliUtil.RunningTitle();
            _running = true;

            // Commands
            var commands = new ConsoleCommands();

            commands.Wait();
        }
Ejemplo n.º 12
0
		/// <summary>
		/// Loads all necessary components and starts the server.
		/// </summary>
		public void Run()
		{
			if (_running)
				throw new Exception("Server is already running.");

			CliUtil.WriteHeader("Web Server", ConsoleColor.DarkRed);
			CliUtil.LoadingTitle();

			this.NavigateToRoot();

			// Conf
			this.LoadConf(this.Conf = new WebConf());

			// Database
			this.InitDatabase(this.Database = new AuraDb(), this.Conf);

			// Server
			this.StartWebServer();

			// Scripts (after web server)
			this.LoadScripts();

			CliUtil.RunningTitle();
			_running = true;

			// Commands
			var commands = new ConsoleCommands();
			commands.Wait();
		}
Ejemplo n.º 13
0
        private static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            var sw = new Stopwatch();

            sw.Start();
            Console.CursorVisible = false;
            Cli.WriteHeader(Localization.Get("Title"), Localization.Get("Header"), ConsoleColor.Red);
            Cli.LoadingTitle();
            Logger.Progress(0, ProgressStep);

            //Logger Settings Up
            Logger.Archive = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Logs");
            Logger.LogFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Logs",
                                          "Comidat.log");
            Logger.Progress(1, ProgressStep);

            //Console commands activating
            var console = new ConsoleCommands();

            //Logger.Hide ^= LogLevel.Debug;
            Logger.Progress(2, ProgressStep);

            //Settings up server
            IServer server = new TCP();

            server.Connected       += ServerOnConnected;
            server.Disconnected    += ServerOnDisconnected;
            server.MessageReceived += ServerOnMessageReceived;
            server.StartAsync(new IPEndPoint(IPAddress.Any, 5757));
            Logger.Progress(3, ProgressStep);

            //Settings up Database
            //Global.Database.Database.Migrate();
            Logger.Progress(4, ProgressStep);

            //Seed TBLReaders for testing
            //Global.SeedReaders();
            //Global.SeedTags();
            //Global.Database.SaveChanges();
            Logger.Progress(5, ProgressStep);

            Global.LoadReaders();
            Logger.Progress(6, ProgressStep);

            //Global.SeedForTestFromFile();

            Logger.Progress(ProgressStep, ProgressStep);
            Logger.Info(Localization.Get("Comidat.Program.MainB.LoadingTime"), sw.ElapsedMilliseconds);
            sw.Stop();

            Cli.RunningTitle();

            //Test().Wait(0);

            Global.SaveDataBaseAync().Wait(0);

            console.Wait();
        }
Ejemplo n.º 14
0
 private static void Commands_Execute(params string[] args)
 {
     foreach (Command c in ConsoleCommands.OrderBy(x => x.Key).ToList())
     {
         SendMessage(new Message(c.Key, Message.MessageType.Information));
     }
 }
Ejemplo n.º 15
0
        private string ListAllCommands(ConsoleCommands Commands, string CategoryName = null)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var command in Commands.GetCommands())
            {
                sb.Append(Environment.NewLine);
                if (CategoryName != null)
                {
                    sb.Append(CategoryName + ' ');
                }
                sb.Append(FormatCommandHelp(command));
            }

            var subcates = Commands.GetSubCategories();

            if (subcates.Count != 0)
            {
                foreach (var subcate in subcates)
                {
                    if (CategoryName != null)
                    {
                        sb.Append(ListAllCommands(subcate.Value, CategoryName + ' ' + subcate.Key));
                    }
                    else
                    {
                        sb.Append(ListAllCommands(subcate.Value, subcate.Key));
                    }
                }
            }

            return(sb.ToString());
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            ConsoleUtils.ShowHeader();

            Config conf = new Config();

            if (!conf.Read("conf/game-server.txt"))
            {
                ConsoleUtils.Write(ConsoleMsgType.Info, "Press a key to end.\n");
                Console.ReadKey();
                return;
            }
            else if (!conf.Read("conf/inter-server.txt"))
            {
                ConsoleUtils.Write(ConsoleMsgType.Info, "Press a key to end.\n");
                Console.ReadKey();
                return;
            }

            if (conf.Data.ContainsKey("console_silent"))
            {
                int consoleSilent;
                if (Int32.TryParse(conf.Data["console_silent"], out consoleSilent))
                {
                    ConsoleUtils.SetDisplaySettings((ConsoleMsgType)consoleSilent);
                }
                else
                {
                    ConsoleUtils.Write(ConsoleMsgType.Error, "Invalid 'console_silent' value.\n");
                }
            }

            Settings.Set(conf.Data);
            Server sv = new Server();

            ConsoleCommands.LoadCommands(GetConsoleCmdList());
            do
            {
                if (!ConsoleCommands.OnInputReceived(Console.ReadLine()))
                {
                    break;
                }
            } while (true);

            ConsoleUtils.Write(ConsoleMsgType.Info, "Ending server execution...\n");

            /* Console Debug
             * ConsoleUtils.Write(ConsoleMsgType.None, "Msg0\n");
             * ConsoleUtils.Write(ConsoleMsgType.Info, "Msg1\n");
             * ConsoleUtils.Write(ConsoleMsgType.Status, "Msg2\n");
             * ConsoleUtils.Write(ConsoleMsgType.Notice, "Msg4\n");
             * ConsoleUtils.Write(ConsoleMsgType.Warning, "Msg8\n");
             * ConsoleUtils.Write(ConsoleMsgType.Error, "Msg16\n");
             * ConsoleUtils.Write(ConsoleMsgType.Debug, "Msg32\n");
             * ConsoleUtils.Write(ConsoleMsgType.SQL, "Msg64\n");
             * ConsoleUtils.Write(ConsoleMsgType.FatalError, "Msg128\n");
             * ConsoleUtils.Write(ConsoleMsgType.PacketDebug, "Msg256\n");
             */
        }
Ejemplo n.º 17
0
    private void HandleInputs()
    {
        if (btnConsole.Check() == InputStates.InputState.JustPressed)
        {
            if (visible)
            {
                Hide();
            }
            else
            {
                Show();
            }
        }

        if (btnEnter.Check() == InputStates.InputState.JustPressed)
        {
            string   command = inputText.text;
            string[] tokens  = command.Split(' ', '\t', '\n');
            string   output  = "";
            if (command.Length > 0)
            {
                ConsoleCommands.Execute(tokens.Length, tokens, ref output, this);
                if (!storedCommands.Contains(command))
                {
                    storedCommands.Add(command);
                }
                if (storedCommands.Count > 16)
                {
                    storedCommands.RemoveAt(0);
                }
            }
            outputText.text += ">>> " + output + "\n";
        }

        if (btnDown.Check() == InputStates.InputState.JustPressed)
        {
            if (storedCommands.Count > 0)
            {
                instrIdx -= 1;
                if (instrIdx < 0)
                {
                    instrIdx = storedCommands.Count - 1;
                }
                string command = storedCommands[instrIdx];
                inputText.text = command;
            }
        }

        if (btnUp.Check() == InputStates.InputState.JustPressed)
        {
            if (storedCommands.Count > 0)
            {
                instrIdx = (instrIdx + 1) % storedCommands.Count;
                string command = storedCommands[instrIdx];
                inputText.text = command;
            }
        }
    }
Ejemplo n.º 18
0
        /// <summary>
        /// This is the application main entry point
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            // Run the singleton Server instance.
            ServerMain.Instance.Run();
            // Push the Server Command out onto Main Class to decouple certain features.
            var x = new ConsoleCommands();

            x.Wait();
        }
Ejemplo n.º 19
0
 // Initialize
 private void Awake()
 {
     ConsoleCommands.AddCommand("Timer.Start", timerStart, "Starts the timer");
     ConsoleCommands.AddCommand("Timer.Pause", timerPause, "Pauses the timer");
     ConsoleCommands.AddCommand("Timer.Stop", timerStop, "Stops the timer");
     ConsoleCommands.AddCommand("Timer.TickBy", tickBy, "Changes how much the timer ticks by");
     ConsoleCommands.AddCommand("Disco", disco, "Disco Mode!");
     ConsoleCommands.AddCommand("Disco.Stop", discoStop, "Stops discomode");
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Teleports the local player to specific coordinates of a location using the warp console command. May have unexepected results if used on a remote player.
        /// This method allows the original game code to flag a player as waiting for other players when entering a festival location.
        /// </summary>
        /// <param name="location">The name of the location</param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public static void TeleportThisPlayer(Location location, int x, int y)
        {
            //TODO: throw exception to be caught by logging higher up
            if (location == Location.None)
            {
                return;
            }

            ConsoleCommands.RunCommand(ConsoleCommands.BuildWarpCommand(location, x, y));
        }
Ejemplo n.º 21
0
        public static void TeleportThisPlayer(string location, int x, int y)
        {
            //TODO: throw exception to be caught by logging higher up
            if (String.IsNullOrWhiteSpace(location))
            {
                return;
            }

            ConsoleCommands.RunCommand(ConsoleCommands.BuildWarpCommand(location, x, y));
        }
Ejemplo n.º 22
0
        private void RegisterCommands()
        {
            ConsoleCommands.Add("chat", new PublicChat());
            ConsoleCommands.Add("chat_team", new TeamChat());
            ConsoleCommands.Add("chat_private", new PrivateChat());
            ConsoleCommands.Add("chat_help", new Help(this));

            RemoteAdminCommands.Add("chat_mute", new Mute());
            RemoteAdminCommands.Add("chat_unmute", new Unmute());
            RemoteAdminCommands.Add("chat_delete_mutes", new DeleteMutes());
            RemoteAdminCommands.Add("chat_show_mutes", new ShowMutes());
        }
Ejemplo n.º 23
0
        public static void ExecuteCommand(string Command)
        {
            string[] args = ParseCommand(Command);
            switch (Command.Split(' ').First())
            {
            case "analysis":
                break;

            case "console":
                ConsoleCommands.Execute(args);
                break;
            }
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Console commands handler
 /// </summary>
 private static void KeepAlive()
 {
     while (true)
     {
         var l = Console.ReadLine();
         if (l != "")
         {
             if (l.StartsWith("/"))
             {
                 ConsoleCommands.Handle(l);
             }
         }
     }
 }
Ejemplo n.º 25
0
        static void Main(string[] args)
        {
            //ServerMain.Instance.Run();
            Log.Info("Initialized LoadTestingRunner");
            Console.WriteLine("(1) GameServer Load Test: 100 clients spam NullPingAck packets");
            Console.WriteLine("(2) GameServer Load Test: 100 clients spam CmdUserAuth packets");
            Console.WriteLine("(3) ApiServer Load Test: Spam GET requests to /questions");

            Console.WriteLine("Enter option (1, 2, 3):");
            string input            = Console.ReadLine();
            int    testDurationInMs = 2000;

            int option;

            if (Int32.TryParse(input, out option))
            {
                switch (option)
                {
                case 1:
                case 2:
                    ServerLoadTest serverLoadTest = new ServerLoadTest(testDurationInMs);
                    if (option == 1)
                    {
                        serverLoadTest.SpamNullPingAcks();
                    }
                    if (option == 2)
                    {
                        serverLoadTest.SpamLoginCmds();
                    }
                    break;

                case 3:
                    ApiLoadTest apiLoadTest = new ApiLoadTest(testDurationInMs);
                    apiLoadTest.Run();
                    break;

                default:
                    Log.Error("No such option.");
                    break;
                }
            }
            else
            {
                Log.Error("No such option.");
            }

            var x = new ConsoleCommands();

            x.Wait();
        }
Ejemplo n.º 26
0
        private string autoCompleteParameters(string incompleteCommand)
        {
            var splitBySpace = incompleteCommand.Split(space, StringSplitOptions.RemoveEmptyEntries);

            if (splitBySpace.Length == 0 || splitBySpace.Length > 2)
            {
                return(incompleteCommand);
            }

            var command           = splitBySpace[0];
            var parameterPrefixes = ConsoleCommands.ParameterPrefixesFor(command);

            if (parameterPrefixes == null)
            {
                logger.Info($"> {incompleteCommand}");
                logger.Warn("No parameters for command known.");
                return(incompleteCommand);
            }

            var parameter = splitBySpace.Length > 1 ? splitBySpace[1] : "";
            var extended  = parameterPrefixes.ExtendPrefix(parameter);

            if (extended == null)
            {
                logger.Info($"> {incompleteCommand}");
                logger.Warn("No matching parameters found.");
                return(incompleteCommand);
            }

            if (parameterPrefixes.Contains(extended))
            {
                return($"{command} {extended} ");
            }

            if (extended != parameter)
            {
                return($"{command} {extended}");
            }

            var availableParameters = parameterPrefixes.AllKeys(extended);

            logger.Info($"> {command} {extended}");
            foreach (var p in availableParameters)
            {
                logger.Info(p);
            }

            return($"{command} {extended}");
        }
Ejemplo n.º 27
0
        static void Main(string[] args)
        {
            //Log.Archive = Environment.CurrentDirectory + @"/Log/";
            //Log.LogFile = Log.Archive + AppDomain.CurrentDomain.FriendlyName.Replace(".exe", ".txt");

            tc = new List<TestClient>();
            Shared.Util.CliUtil.WriteHeader("Client", ConsoleColor.Green);

            console = new ConsoleCommands();
            console.Add("AddClient", "<count>", "Add client for test", HandleAddClient);
            console.Add("CloseAll", "Close all client", HandleCloseAll);
            console.Add("Login", "<username> <password>", "Login Request", HandleLogin);

            console.Wait();
        }
Ejemplo n.º 28
0
        private static void InitiateConsole()
        {
            DisableSizing();

            Console.SetOut(new Out());
            Console.CursorVisible = false;

            Draw.Logo();

            //TODO: Add QuestBuilder();
            //RewardBuilder();
            InitiateSession();
            ConsoleUpdater();
            ConsoleCommands.Add();
            KeepAlive();
        }
Ejemplo n.º 29
0
    /// <summary>
    /// Clear all caches at the end of the day and if the player exits to menu.
    /// </summary>
    private void ClearCaches()
    {
        DialoguePatches.ClearTalkRecord();
        DialogueUtilities.ClearDialogueLog();

        if (Context.IsSplitScreen && Context.ScreenId != 0)
        {
            return;
        }
        this.haveFixedSchedulesToday = false;
        MidDayScheduleEditor.Reset();
        IslandSouthPatches.ClearCache();
        GIScheduler.ClearCache();
        GIScheduler.DayEndReset();
        ConsoleCommands.ClearCache();
        ScheduleUtilities.ClearCache();
    }
Ejemplo n.º 30
0
        protected override void OnLoad(EventArgs e)
        {
            ConsoleCommands.Initialise();

            renderContext = new RenderContext();

            inputManager = new InputManager(Mouse);

            screenManager = new ScreenManager(inputManager);

            screenManager.AddScreenLayerOnTop(new LobbyScreen(screenManager, renderContext.Geometries, logger, inputManager));
            screenManager.AddScreenLayerOnTop(new ConsoleScreenLayer(screenManager, renderContext.Geometries, logger));

            KeyPress += (sender, args) => screenManager.RegisterPressedCharacter(args.KeyChar);

            OnResize(EventArgs.Empty);
        }
Ejemplo n.º 31
0
        private static void InitiateConsole()
        {
            Draw.Logo();

            if (INTERACTIVE_CONSOLE)
            {
                DisableSizing();
                Console.CursorVisible = false;
            }


            //RewardBuilder();
            InitiateSession();
            ConsoleUpdater();
            ConsoleCommands.Add();
            KeepAlive();
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Starts the server.
        /// </summary>
        public override void Run()
        {
            base.Run();

            CliUtil.WriteHeader("Login", ConsoleColor.Magenta);
            CliUtil.LoadingTitle();

            // Conf
            this.LoadConf();

            // Database
            this.Database = new LoginDb();
            this.InitDatabase(this.Database);

            // Check if there are any updates
            this.CheckDatabaseUpdates();

            // Data
            this.LoadData(DataToLoad.Jobs | DataToLoad.Maps | DataToLoad.Barracks | DataToLoad.Servers | DataToLoad.StartingCities, true);

            // Packet handlers
            LoginPacketHandler.Instance.RegisterMethods();

            // Get server data
            var serverId   = 1;
            var serverData = this.Data.ServerDb.FindLogin(serverId);

            if (serverData == null)
            {
                Log.Error("Server data not found. ({0})", serverId);
                CliUtil.Exit(1);
            }

            // Server
            var mgr = new ConnectionManager <LoginConnection>(serverData.Port);

            mgr.Start();

            // Ready
            CliUtil.RunningTitle();
            Log.Status("Server ready, listening on {0}.", mgr.Address);

            // Commands
            this.ConsoleCommands = new LoginConsoleCommands();
            this.ConsoleCommands.Wait();
        }
Ejemplo n.º 33
0
        public EthernetIntersystemCommunications Create()
        {
            var eisc = new EthernetIntersystemCommunications(0x09, "10.51.10.112", ProAvControlSystem.ControlSystem);

            eisc.Register();
            eisc.OnlineStatusChange += EiscOnOnlineStatusChange;
            ConsoleCommands.Create(x_ => {
                uint join;
                x_.TryParseToUint(out join);
                eisc.BooleanInput[join].Pulse(1000);
            }, "testbool", "testbool joinnumber");
            ConsoleCommands.Create(x_ => {
                uint join;
                x_.TryParseToUint(out join);
                eisc.StringInput[x_].StringValue = DateTime.Now.ToLongTimeString();
            }, "testserial", "testserial joinnumber");
            return(eisc);
        }
Ejemplo n.º 34
0
        static void Main(string[] args)
        {
            Log.Archive = Environment.CurrentDirectory + @"/Log/";
            Log.LogFile = Log.Archive + AppDomain.CurrentDomain.FriendlyName.Replace(".exe", ".txt");

            Localization.Parse(Environment.CurrentDirectory, "*.lang", System.IO.SearchOption.AllDirectories);
            CliUtil.WriteHeader(Localization.Get("Server.Program.Main.Title"), ConsoleColor.Red);

            CliUtil.LoadingTitle();

            var console = new ConsoleCommands();
            console.Add("status", "<GCollet:Bool>", Localization.Get("Server.Program.Main.ConsoleCommands.Description.Status"), HandleStatus);
            console.Add("ChangeCrypter", "<port>", Localization.Get("Server.Program.Main.ConsoleCommands.Description.ChangeCrypter"), HandleChangeCrypter);
            console.Add("Ping", "<port>", Localization.Get("Server.Program.Main.ConsoleCommands.Description.Ping"), HandlePing);

            ts = new TestServer();
            ts.Start(8080);

            CliUtil.RunningTitle();
            console.Wait();
        }
Ejemplo n.º 35
0
        private async void RunCommand(ConsoleCommands command)
        {
            try
            {
                output.Text = "";
                ObserverSettings settings;
                switch (command)
                {
                    case ConsoleCommands.NodeServer:
                        await RunningApp.PollerService.Stop();
                        settings = RunningApp.Data.Settings;

                        settings.Servers.Add(new ObserverServer
                        {
                            Name = "Node JS",
                            Url = "http://jenkins.nodejs.org/",
                            Healthy = true,
                        });

                        RunningApp.Data.Settings = settings;
                        RunningApp.OpenSettings();
                        break;

                    case ConsoleCommands.TestNotifications:
                        settings = RunningApp.Data.Settings;
                        var server = settings.Servers.FirstOrDefault() ?? new ObserverServer();
                        var job = server.Jobs.FirstOrDefault() ?? new ObserverJob();
                        foreach (var ct in Enum.GetValues(typeof (ChangeType)).Cast<ChangeType>())
                        {
                            output.Text += ct.ToString() + '\n';
                            RunningApp.JobChanged(RunningApp.Poller, server, job, ct);
                            await Task.Delay(10000);
                        }
                        break;

                    case ConsoleCommands.GetSettingsJson:
                        await RunningApp.PollerService.Stop();
                        output.Text = RunningApp.Data.SettingsAsJson;
                        break;

                    case ConsoleCommands.DeleteSettings:
                        await RunningApp.PollerService.Stop();
                        RunningApp.Data.Delete();
                        break;

                    case ConsoleCommands.Settings:
                        RunningApp.OpenSettings();
                        break;

                    case ConsoleCommands.PollerRunning:
                        output.Text = RunningApp.PollerService.IsRunning.ToString();
                        break;

                    case ConsoleCommands.PollerStart:
                        RunningApp.PollerService.Start();
                        break;

                    case ConsoleCommands.PollerStop:
                        await RunningApp.PollerService.Stop();
                        break;

                    default:
                        throw new InvalidOperationException("Command Not Supported");
                }
            }
            catch (Exception ex)
            {
                output.Text = ex.ToString();
            }
        }
Ejemplo n.º 36
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Server"/> class.
        /// </summary>
        /// <exception cref="NotSupportedException">NetGore does not support systems that are not in Little Endian mode!</exception>
        public Server()
        {
            // Check for some system settings
            if (!BitConverter.IsLittleEndian)
            {
                const string errmsg = "NetGore does not support systems that are not in Little Endian mode!";
                log.Fatal(errmsg);
                throw new NotSupportedException(errmsg);
            }

            // Initialize the engine settings
            EngineSettingsInitializer.Initialize();

            // Create the DbController
            var settings = new DbConnectionSettings();
            _dbController =
                settings.CreateDbControllerPromptEditWhenInvalid(x => new ServerDbController(x.GetMySqlConnectionString()),
                    x => PromptEditDbSettingsFile(settings, x));

            if (_dbController == null)
                return;

            // Add the query stats tracker
            var queryStats = new BasicQueryStatsTracker { LogFilePath = ContentPaths.Build.Root.Join("querystats.txt") };
            queryStats.LogFileFrequency = 1000 * 5;
            _dbController.ConnectionPool.QueryStats = queryStats;

            // Validate the database
            DbTableValidator.ValidateTables(_dbController);
            ValidateDbControllerQueryAttributes();

            // Clean-up
            var cleaner = new ServerCleaner(this);
            cleaner.Run();

            // Load the game data and such
            InitializeScripts();

            // Create some objects
            _consoleCommands = new ConsoleCommands(this);
            _groupManager = new GroupManager((gm, x) => new Group(x));
            _userAccountManager = new UserAccountManager(DbController);
            _world = new World(this);
            _sockets = new ServerSockets(this);

            WorldStatsTracker.Instance.NetPeerToTrack = _sockets.GetNetServer();

            // Check for the password salt
            if (string.IsNullOrEmpty(ServerSettings.Default.PasswordSalt))
            {
                const string errmsg =
                    "No password salt has been defined in the server settings file. Make sure you define one before releasing.";
                if (log.IsWarnEnabled)
                    log.WarnFormat(errmsg);
            }

            // Set the thread priority
            SetThreadPriority(ServerSettings.Default.ThreadPriority);

            // Validate the server's settings
            var ssv = new ServerSettingsValidator();
            ssv.Check(this);

            if (log.IsInfoEnabled)
                log.Info("Server loaded.");
        }
 public void SetUp()
 {
     resolver.Resolve(typeof(TestCommand));
     consoleCommands = ConsoleCommands.Current;
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Server"/> class.
        /// </summary>
        /// <exception cref="NotSupportedException">NetGore does not support systems that are not in Little Endian mode!</exception>
        public Server()
        {
            ThreadAsserts.IsMainThread();

            // Check for some system settings
            if (!BitConverter.IsLittleEndian)
            {
                const string errmsg = "NetGore does not support systems that are not in Little Endian mode!";
                log.Fatal(errmsg);
                throw new NotSupportedException(errmsg);
            }

            // Check if patching is needed
            int numMissingPatches = -1;
            try
            {
                numMissingPatches = ServerDbPatcher.GetMissingPatches().Length;
            }
            catch (Exception ex)
            {
                log.WarnFormat("Failed to find DbPatches directory, so could not check if patching is required. Exception: {0}", ex);
            }

            if (numMissingPatches > 0)
            {
                log.ErrorFormat("There are `{0}` NetGore db patches not applied. Please backup your database then run /DemoGame.Server/DbPatches/Patch.bat.", numMissingPatches);
                log.ErrorFormat("Server will auto-close after 10 seconds, and will keep doing this until you patch.");
                Thread.Sleep(10 * 1000);
                return;
            }

            // Initialize the engine settings
            EngineSettingsInitializer.Initialize();

            // Create the DbController
            _dbController = CreateDbController();

            // Add the query stats tracker
            var queryStats = new BasicQueryStatsTracker { LogFilePath = ContentPaths.Build.Root.Join("querystats.txt") };
            queryStats.LogFileFrequency = 1000 * 5;
            _dbController.ConnectionPool.QueryStats = queryStats;

            // Validate the database
            DbTableValidator.ValidateTables(_dbController);
            ValidateDbControllerQueryAttributes();

            // Clean-up
            var cleaner = new ServerCleaner(this);
            cleaner.Run();

            // Create some objects
            _consoleCommands = new ConsoleCommands(this);
            _groupManager = new GroupManager((gm, x) => new Group(x));
            _userAccountManager = new UserAccountManager(DbController);
            _world = new World(this);
            _sockets = new ServerSockets(this);

            WorldStatsTracker.Instance.NetPeerToTrack = _sockets.GetNetServer();

            // Check for the password salt
            if (string.IsNullOrEmpty(ServerSettings.Default.PasswordSalt))
            {
                const string errmsg =
                    "No password salt has been defined in the server settings file. Make sure you define one before releasing.";
                if (log.IsWarnEnabled)
                    log.WarnFormat(errmsg);
            }

            // Set the thread priority
            SetThreadPriority(ServerSettings.Default.ThreadPriority);

            // Validate the server's settings
            var ssv = new ServerSettingsValidator();
            ssv.Check(this);

            if (log.IsInfoEnabled)
                log.Info("Server loaded.");
        }