Exemple #1
0
        public void DoCommand(string cmd, LLUUID fromAgentID)
        {
            string[] tokens;

            try { tokens = Parsing.ParseArguments(cmd); }
            catch (FormatException ex) { Console.WriteLine(ex.Message); return; }

            if (tokens.Length == 0)
            {
                return;
            }

            string firstToken = tokens[0].ToLower();

            // "all balance" will send the balance command to all currently logged in bots
            if (firstToken == "all" && tokens.Length > 1)
            {
                cmd = String.Empty;

                // Reserialize all of the arguments except for "all"
                for (int i = 1; i < tokens.Length; i++)
                {
                    cmd += tokens[i] + " ";
                }

                ClientManager.DoCommandAll(cmd, fromAgentID);

                return;
            }

            if (Commands.ContainsKey(firstToken))
            {
                string[] args = new string[tokens.Length - 1];
                Array.Copy(tokens, 1, args, 0, args.Length);
                string response = Commands[firstToken].Execute(args, fromAgentID);

                if (!String.IsNullOrEmpty(response))
                {
                    Console.WriteLine(response);

                    if (fromAgentID != LLUUID.Zero && Network.Connected)
                    {
                        // IMs don't like \r\n line endings, clean them up first
                        response = response.Replace("\r", String.Empty);
                        SendResponseIM(this, fromAgentID, response);
                    }
                }
            }
        }
        public void DoCommand(string cmd, LLUUID fromAgentID, LLUUID imSessionID)
        {
            string[] tokens     = cmd.Trim().Split(new char[] { ' ', '\t' });
            string   firstToken = tokens[0].ToLower();

            if (tokens.Length == 0)
            {
                return;
            }

            // "all balance" will send the balance command to all currently logged in bots
            if (firstToken == "all" && tokens.Length > 1)
            {
                cmd = "";

                // Reserialize all of the arguments except for "all"
                for (int i = 1; i < tokens.Length; i++)
                {
                    cmd += tokens[i] + " ";
                }

                ClientManager.DoCommandAll(cmd, fromAgentID, imSessionID);

                return;
            }

            if (Commands.ContainsKey(firstToken))
            {
                string[] args = new string[tokens.Length - 1];
                Array.Copy(tokens, 1, args, 0, args.Length);
                string response = response = Commands[firstToken].Execute(args, fromAgentID);

                if (response.Length > 0)
                {
                    if (fromAgentID != null && Network.Connected)
                    {
                        SendResponseIM(this, fromAgentID, response, imSessionID);
                    }

                    Console.WriteLine(response);
                }
            }
        }