corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.Text; |
||
4 | using OpenMetaverse; |
||
5 | using OpenMetaverse.Packets; |
||
6 | |||
7 | namespace OpenMetaverse.TestClient |
||
8 | { |
||
9 | public class BotsCommand : Command |
||
10 | { |
||
11 | private Dictionary<UUID, bool> m_AgentList = new Dictionary<UUID, bool>(); |
||
12 | |||
13 | public BotsCommand(TestClient testClient) |
||
14 | { |
||
15 | Name = "bots"; |
||
16 | Description = "detects avatars that appear to be bots."; |
||
17 | Category = CommandCategory.Other; |
||
18 | testClient.Avatars.ViewerEffect += new EventHandler<ViewerEffectEventArgs>(Avatars_ViewerEffect); |
||
19 | testClient.Avatars.ViewerEffectLookAt += new EventHandler<ViewerEffectLookAtEventArgs>(Avatars_ViewerEffectLookAt); |
||
20 | testClient.Avatars.ViewerEffectPointAt += new EventHandler<ViewerEffectPointAtEventArgs>(Avatars_ViewerEffectPointAt); |
||
21 | } |
||
22 | |||
23 | private void Avatars_ViewerEffectPointAt(object sender, ViewerEffectPointAtEventArgs e) |
||
24 | { |
||
25 | lock (m_AgentList) |
||
26 | { |
||
27 | if (m_AgentList.ContainsKey(e.SourceID)) |
||
28 | m_AgentList[e.SourceID] = true; |
||
29 | else |
||
30 | m_AgentList.Add(e.SourceID, true); |
||
31 | } |
||
32 | } |
||
33 | |||
34 | private void Avatars_ViewerEffectLookAt(object sender, ViewerEffectLookAtEventArgs e) |
||
35 | { |
||
36 | lock (m_AgentList) |
||
37 | { |
||
38 | if (m_AgentList.ContainsKey(e.SourceID)) |
||
39 | m_AgentList[e.SourceID] = true; |
||
40 | else |
||
41 | m_AgentList.Add(e.SourceID, true); |
||
42 | } |
||
43 | } |
||
44 | |||
45 | private void Avatars_ViewerEffect(object sender, ViewerEffectEventArgs e) |
||
46 | { |
||
47 | lock (m_AgentList) |
||
48 | { |
||
49 | if (m_AgentList.ContainsKey(e.SourceID)) |
||
50 | m_AgentList[e.SourceID] = true; |
||
51 | else |
||
52 | m_AgentList.Add(e.SourceID, true); |
||
53 | } |
||
54 | } |
||
55 | |||
56 | public override string Execute(string[] args, UUID fromAgentID) |
||
57 | { |
||
58 | StringBuilder result = new StringBuilder(); |
||
59 | |||
60 | lock (Client.Network.Simulators) |
||
61 | { |
||
62 | for (int i = 0; i < Client.Network.Simulators.Count; i++) |
||
63 | { |
||
64 | Client.Network.Simulators[i].ObjectsAvatars.ForEach( |
||
65 | delegate(Avatar av) |
||
66 | { |
||
67 | lock (m_AgentList) |
||
68 | { |
||
69 | if (!m_AgentList.ContainsKey(av.ID)) |
||
70 | { |
||
71 | result.AppendLine(); |
||
72 | result.AppendFormat("{0} (Group: {1}, Location: {2}, UUID: {3} LocalID: {4}) Is Probably a bot", |
||
73 | av.Name, av.GroupName, av.Position, av.ID, av.LocalID); |
||
74 | } |
||
75 | } |
||
76 | } |
||
77 | ); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | return result.ToString(); |
||
82 | } |
||
83 | } |
||
84 | } |