From 99c7e87979fdeb086bbb93aeb33aee2fb4e76f87 Mon Sep 17 00:00:00 2001 From: lancej Date: Tue, 14 Nov 2006 09:12:30 +0000 Subject: [PATCH] * TestBot now only accepts commands/teleports from members of its group. git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@584 52acb1d6-8a22-11de-b505-999d5b087335 --- applications/TestBot/TestBot.cs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/applications/TestBot/TestBot.cs b/applications/TestBot/TestBot.cs index da2928b3..0eb09782 100644 --- a/applications/TestBot/TestBot.cs +++ b/applications/TestBot/TestBot.cs @@ -10,6 +10,7 @@ namespace TestBot { SecondLife Client; LLUUID myGroupID; + Dictionary myGroupMembers; Dictionary prims; Dictionary avatars; @@ -89,11 +90,20 @@ namespace TestBot if (tokens.Length == 0) return; + string response = ""; if (commands.ContainsKey(tokens[0])) { string[] args = new string[tokens.Length - 1]; Array.Copy(tokens, 1, args, 0, args.Length); - string response = commands[tokens[0]].Invoke(args); + response = commands[tokens[0]].Invoke(args); + } + else + { + response = "Unknown command."; + } + + if (response.Length > 0) + { if (fromAgentID != null) { Client.Self.InstantMessage(fromAgentID, response, imSessionID); @@ -165,7 +175,18 @@ namespace TestBot { AgentDataUpdatePacket p = (AgentDataUpdatePacket)packet; if (p.AgentData.AgentID == Client.Network.AgentID) + { + Console.WriteLine("Got my group ID, requesting group members..."); myGroupID = p.AgentData.ActiveGroupID; + + Client.Groups.BeginGetGroupMembers(myGroupID, new GroupManager.GroupMembersCallback(OnGroupMembers)); + } + } + + void OnGroupMembers(Dictionary members) + { + Console.WriteLine("Got " + members.Count + " group members."); + myGroupMembers = members; } void Objects_OnObjectKilled(Simulator simulator, uint objectID) @@ -227,6 +248,12 @@ namespace TestBot { Console.WriteLine("" + fromAgentName + ": " + message + "\n"); + if (myGroupMembers != null && !myGroupMembers.ContainsKey(fromAgentID)) + { + //Not a member of my group, ignore the IM. + return; + } + if (dialog == 22) { Console.WriteLine("Accepting teleport lure.");