Ejemplo n.º 1
0
 private static void SendReply(List <string> args, ICRCSendable output)
 {
     if (!CRCClient.SendReply(args[0]))
     {
         output.AddError("You can't reply if you haven't been sent any messages yet.");
     }
 }
Ejemplo n.º 2
0
 private static void ShowHelp(List <string> args, ICRCSendable output)
 {
     foreach (CRCCommand command in commands)
     {
         if (command.Name == args[0])
         {
             output.AddInformation(command.Help);
             return;
         }
     }
     output.AddError("Command \"" + args[0] + "\" not recognized. Use /commands to see all available commands.");
 }
Ejemplo n.º 3
0
        private static void ChangeNick(List <string> args, ICRCSendable output)
        {
            string nick   = args[0].Replace(' ', '_');
            string result = CRCStrings.ValidateNick(nick);

            if (result != null)
            {
                output.AddError(result);
            }
            else
            {
                CRCClient.ChangeNick(nick);
            }
        }
Ejemplo n.º 4
0
        public static void ProcessCommand(string message, ICRCSendable output)
        {
            Match  commandMatch  = commandRx.Match(message);
            string commandString = commandMatch.Groups[1].Value;
            string args          = commandMatch.Groups[2].Value;

            foreach (CRCCommand command in commands)
            {
                if (command.Name == commandString)
                {
                    command.Process(args, output);
                    return;
                }
            }
            output.AddError("Command \"" + commandString + "\" not recognized. Use /commands to see all available commands.");
        }
Ejemplo n.º 5
0
        public void Process(string input, ICRCSendable output)
        {
            List <string>   args       = new List <string>();
            MatchCollection argMatches = argRx.Matches(input);

            if (argMatches.Count < argCount || (argMatches.Count > argCount && !longArg))
            {
                output.AddError(usage);
                return;
            }
            for (int index = 0; index < argCount; index++)
            {
                if (index == (argCount - 1) && longArg)
                {
                    args.Add(input.Substring(argMatches[index].Index));
                }
                else
                {
                    args.Add(argMatches[index].Value);
                }
            }
            action(args, output);
        }
Ejemplo n.º 6
0
 private static void SendQuery(List <string> args, ICRCSendable output)
 {
     CRCClient.SendQuery(args[0], args[1]);
 }
Ejemplo n.º 7
0
 private static void ShowCommands(List <string> args, ICRCSendable output)
 {
     output.AddInformation("Available commands: " + string.Join(", ", commands));
 }