aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ExportBot/Commands/Communication/IMCommand.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ExportBot/Commands/Communication/IMCommand.cs71
1 files changed, 0 insertions, 71 deletions
diff --git a/ExportBot/Commands/Communication/IMCommand.cs b/ExportBot/Commands/Communication/IMCommand.cs
deleted file mode 100644
index 32d7fff..0000000
--- a/ExportBot/Commands/Communication/IMCommand.cs
+++ /dev/null
@@ -1,71 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Threading;
4using libsecondlife;
5using libsecondlife.Packets;
6
7namespace libsecondlife.TestClient
8{
9 public class ImCommand : Command
10 {
11 string ToAvatarName = String.Empty;
12 ManualResetEvent NameSearchEvent = new ManualResetEvent(false);
13 Dictionary<string, LLUUID> Name2Key = new Dictionary<string, LLUUID>();
14
15 public ImCommand(TestClient testClient)
16 {
17 testClient.Avatars.OnAvatarNameSearch += new AvatarManager.AvatarNameSearchCallback(Avatars_OnAvatarNameSearch);
18
19 Name = "im";
20 Description = "Instant message someone. Usage: im [firstname] [lastname] [message]";
21 }
22
23 public override string Execute(string[] args, LLUUID fromAgentID)
24 {
25 if (args.Length < 3)
26 return "Usage: im [firstname] [lastname] [message]";
27
28 ToAvatarName = args[0] + " " + args[1];
29
30 // Build the message
31 string message = String.Empty;
32 for (int ct = 2; ct < args.Length; ct++)
33 message += args[ct] + " ";
34 message = message.TrimEnd();
35 if (message.Length > 1023) message = message.Remove(1023);
36
37 if (!Name2Key.ContainsKey(ToAvatarName.ToLower()))
38 {
39 // Send the Query
40 Client.Avatars.RequestAvatarNameSearch(ToAvatarName, LLUUID.Random());
41
42 NameSearchEvent.WaitOne(6000, false);
43 }
44
45 if (Name2Key.ContainsKey(ToAvatarName.ToLower()))
46 {
47 LLUUID id = Name2Key[ToAvatarName.ToLower()];
48
49 Client.Self.InstantMessage(id, message, id);
50 return "Instant Messaged " + id.ToStringHyphenated() + " with message: " + message;
51 }
52 else
53 {
54 return "Name lookup for " + ToAvatarName + " failed";
55 }
56 }
57
58 void Avatars_OnAvatarNameSearch(LLUUID queryID, Dictionary<LLUUID, string> avatars)
59 {
60 foreach (KeyValuePair<LLUUID, string> kvp in avatars)
61 {
62 if (kvp.Value.ToLower() == ToAvatarName.ToLower())
63 {
64 Name2Key[ToAvatarName.ToLower()] = kvp.Key;
65 NameSearchEvent.Set();
66 return;
67 }
68 }
69 }
70 }
71}