private void ReadWaitInputs() { while (true) { if (StopConsoleThread == true) { break; } string line = Console.ReadLine(); //Send message event EvtUserMessageArgs umArgs = new EvtUserMessageArgs() { UsrMessage = new EvtUserMsgData(TerminalUsername, TerminalUsername, TerminalUsername, string.Empty, line) }; UserSentMessageEvent?.Invoke(umArgs); //Check for a command if (line.Length > 0 && line[0] == CommandIdentifier) { //Build args list List <string> argsList = new List <string>(line.Split(' ')); string argsAsStr = string.Empty; //Remove the command itself and the space from the string if (argsList.Count > 1) { argsAsStr = line.Remove(0, argsList[0].Length + 1); } //Remove command identifier string cmdText = argsList[0].Remove(0, 1); //Now remove the first entry from the list, which is the command, retaining only the arguments argsList.RemoveAt(0); EvtChatCommandArgs chatcmdArgs = new EvtChatCommandArgs(); EvtUserMsgData msgData = new EvtUserMsgData(TerminalUsername, TerminalUsername, TerminalUsername, string.Empty, line); chatcmdArgs.Command = new EvtChatCommandData(argsList, argsAsStr, msgData, CommandIdentifier, cmdText); ChatCommandReceivedEvent?.Invoke(chatcmdArgs); } } }
private void OnChatCommandReceived(object sender, OnChatCommandReceivedArgs e) { ChatMessage cMsg = e.Command.ChatMessage; EvtUserMsgData msgData = new EvtUserMsgData(cMsg.UserId, cMsg.Username, cMsg.DisplayName, cMsg.Channel, cMsg.Message); EvtChatCommandArgs chatCmdArgs = new EvtChatCommandArgs { Command = new EvtChatCommandData(e.Command.ArgumentsAsList, e.Command.ArgumentsAsString, msgData, e.Command.CommandIdentifier, e.Command.CommandText) }; ChatCommandReceivedEvent?.Invoke(chatCmdArgs); }