Exemplo n.º 1
0
        private void PerformCommand(string command, List <string> args)
        {
            // FIXME: Get first X characters where X is length of cmdchars, to support more-than-one-character command prefix
            if (command[0].ToString() == IrcSettings.Set.cmdchars)
            { // Check for double // command to skip alias processing
                command = command.Substring(1);
            }
            else
            { // Process aliases first and replace command and args appropriately
                foreach (var alias in IrcSettings.Aliases.ToArray())
                {
                    if (command.ToUpper() == alias.Key)
                    {
                        List <string> alias_args = alias.Value.Split(' ').ToList();
                        command = alias_args[0];
                        alias_args.RemoveAt(0);
                        if (alias_args.Count == 0)
                        {
                            alias_args.AddRange(args);
                            args = alias_args;
                        }
                        else
                        {
                            args = Expand.DollarArgs(alias_args, args);
                        }
                    }
                }
            }

            List <string> command_output = new List <string>();

            command_output = Commands.ProcessCommand(command, args);

            if (command_output.Count > 0)
            {
                Channel.EchoList(command_output);
            }
        }