/// <summary> /// Request the text to parse and check for commands that need to be executed. /// </summary> /// <param name="data">A string of data split by char(1), the first part being the command and the second part being the parameters.</param> /// <returns>True if parsed or false if not.</returns> public bool Parse(string data) { if (data.Length == 0 || string.IsNullOrEmpty(data)) { return(false); } string cmd = data.Split(Convert.ToChar(1))[0]; IRCONCommand command = null; if (this._commands.TryGetValue(cmd.ToLower(), out command)) { string param = null; string[] parameters = null; if (data.Split(Convert.ToChar(1))[1] != null) { param = data.Split(Convert.ToChar(1))[1]; parameters = param.ToString().Split(':'); } return(command.TryExecute(parameters)); } return(false); }
public void Register(string commandText, IRCONCommand command) { this._commands.Add(commandText, command); }