示例#1
0
        private void ExecuteCommandIfCommandMessage(ChatMessage chatMessage)
        {
            if (chatMessage.Message[0] == '!')
            {
                string commandName;
                string commandBody;


                int index = chatMessage.Message.IndexOf(' ');
                if (index == -1)
                {
                    commandName = chatMessage.Message;
                    commandBody = null;
                }
                else
                {
                    commandName = chatMessage.Message.Substring(0, index);
                    commandBody = chatMessage.Message.Substring(index + 1);
                }

                ThreadPool.QueueUserWorkItem((o) =>
                {
                    bool result = CommandsController.ExecuteCommandByName(chatMessage, commandName, commandBody);
                });
            }
        }