aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ExportBot/Commands/Communication/SayCommand.cs
blob: d5717a67217e88d1b8ff8cce56eb6fef03e07bd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;

namespace libsecondlife.TestClient
{
    public class SayCommand: Command
    {
        public SayCommand(TestClient testClient)
		{
			Name = "say";
			Description = "Say something.  (usage: say (optional channel) whatever)";
		}

        public override string Execute(string[] args, LLUUID fromAgentID)
		{
            int channel = 0;
            int startIndex = 0;
            
            if (args.Length < 1)
            {
                return "usage: say (optional channel) whatever";
            }
            else if (args.Length > 1)
            {
                if (Int32.TryParse(args[0], out channel))
					startIndex = 1;
            }

            StringBuilder message = new StringBuilder();

			for (int i = startIndex; i < args.Length; i++)
            {
                message.Append(args[i]);
                if (i != args.Length - 1) message.Append(" ");
            }

			Client.Self.Chat(message.ToString(), channel, MainAvatar.ChatType.Normal);

            return "Said " + message.ToString();
		}
    }
}