Esempio n. 1
0
        static void Main(string[] args)
        {
            int i = 0;
            var command = "";
            var lastCommand = 0;

            while (command != "quit")
            {
                var commandParser = new CommandParser();
                Console.Write("[{0}] ", i);
                command = Console.ReadLine();

                Console.WriteLine(commandParser.Parse(command));
                answer = (commandParser.Parse(command));
                i++;

                if (command == "last")
                {

                    Console.WriteLine(answer);
                }

            }

                //Console.ReadLine();
        }
Esempio n. 2
0
        private void ParseAndSend()
        {
            if (Message == null)
                return;

            if (CommandParser.HasNonCommand(Message))
            {
                if (Message.StartsWith("/my "))
                    Message = "/me 's " + Message.Substring("/my ".Length);
                else if (Message.StartsWith("/me's "))
                    Message = "/me 's " + Message.Substring("/me's ".Length);

                SendMessage();
                return;
            }

            try
            {
                var messageToCommand = new CommandParser(Message, model.Id);

                if (!messageToCommand.HasCommand)
                    SendMessage();
                else
                    SendCommand(messageToCommand.ToDictionary());
            }
            catch (ArgumentException ex)
            {
                UpdateError(ex.Message);
            }
            catch (InvalidOperationException ex)
            {
                UpdateError(ex.Message);
            }
        }
Esempio n. 3
0
        private void ParseAndSend()
        {
            if (Message == null)
                return;

            if (CommandParser.HasNonCommand(Message))
            {
                SendMessage();
                return;
            }

            try
            {
                var messageToCommand = new CommandParser(Message, model.Id);

                if (!messageToCommand.HasCommand)
                    SendMessage();
                else if ((messageToCommand.RequiresMod && !HasPermissions)
                         || (messageToCommand.Type.Equals("warn") && !HasPermissions))
                {
                    UpdateError(
                        string.Format("I'm sorry Dave, I can't let you do the {0} command.", messageToCommand.Type));
                }
                else if (messageToCommand.IsValid)
                    SendCommand(messageToCommand.ToDictionary());
                else
                    UpdateError(string.Format("I don't know the {0} command.", messageToCommand.Type));
            }
            catch (InvalidOperationException ex)
            {
                UpdateError(ex.Message);
            }
        }