diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/ChatModule.cs | 248 | ||||
-rw-r--r-- | OpenSim/Region/Environment/PermissionManager.cs | 2 |
2 files changed, 125 insertions, 125 deletions
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index e1a591b..77e038f 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs | |||
@@ -41,18 +41,18 @@ using OpenSim.Region.Environment.Scenes; | |||
41 | namespace OpenSim.Region.Environment.Modules | 41 | namespace OpenSim.Region.Environment.Modules |
42 | { | 42 | { |
43 | public class ChatModule : IRegionModule, ISimChat | 43 | public class ChatModule : IRegionModule, ISimChat |
44 | { | 44 | { |
45 | private List<Scene> m_scenes = new List<Scene>(); | 45 | private List<Scene> m_scenes = new List<Scene>(); |
46 | private LogBase m_log; | 46 | private LogBase m_log; |
47 | 47 | ||
48 | private string m_server = null; | 48 | private string m_server = null; |
49 | private int m_port = 6668; | 49 | private int m_port = 6668; |
50 | private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; | 50 | private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; |
51 | private string m_nick = null; | 51 | private string m_nick = null; |
52 | private string m_channel = null; | 52 | private string m_channel = null; |
53 | 53 | ||
54 | private int m_whisperdistance = 10; | 54 | private int m_whisperdistance = 10; |
55 | private int m_saydistance = 30; | 55 | private int m_saydistance = 30; |
56 | private int m_shoutdistance = 100; | 56 | private int m_shoutdistance = 100; |
57 | 57 | ||
58 | private NetworkStream m_stream; | 58 | private NetworkStream m_stream; |
@@ -71,8 +71,8 @@ namespace OpenSim.Region.Environment.Modules | |||
71 | m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); | 71 | m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); |
72 | m_irc = null; | 72 | m_irc = null; |
73 | m_ircWriter = null; | 73 | m_ircWriter = null; |
74 | m_ircReader = null; | 74 | m_ircReader = null; |
75 | 75 | ||
76 | m_log = OpenSim.Framework.Console.MainLog.Instance; | 76 | m_log = OpenSim.Framework.Console.MainLog.Instance; |
77 | } | 77 | } |
78 | 78 | ||
@@ -89,17 +89,17 @@ namespace OpenSim.Region.Environment.Modules | |||
89 | } | 89 | } |
90 | } catch (Exception e) { | 90 | } catch (Exception e) { |
91 | Console.WriteLine("No IRC config information, skipping IRC bridge configuration"); | 91 | Console.WriteLine("No IRC config information, skipping IRC bridge configuration"); |
92 | } | 92 | } |
93 | 93 | ||
94 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance"); | 94 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance"); |
95 | m_saydistance = config.Configs["Chat"].GetInt("say_distance"); | 95 | m_saydistance = config.Configs["Chat"].GetInt("say_distance"); |
96 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance"); | 96 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance"); |
97 | 97 | ||
98 | if (!m_scenes.Contains(scene)) | 98 | if (!m_scenes.Contains(scene)) |
99 | { | 99 | { |
100 | m_scenes.Add(scene); | 100 | m_scenes.Add(scene); |
101 | scene.EventManager.OnNewClient += NewClient; | 101 | scene.EventManager.OnNewClient += NewClient; |
102 | scene.RegisterModuleInterface<ISimChat>(this); | 102 | scene.RegisterModuleInterface<ISimChat>(this); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
@@ -177,18 +177,18 @@ namespace OpenSim.Region.Environment.Modules | |||
177 | Console.WriteLine(inputLine); | 177 | Console.WriteLine(inputLine); |
178 | if (inputLine.Contains(m_channel)) | 178 | if (inputLine.Contains(m_channel)) |
179 | { | 179 | { |
180 | string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); | 180 | string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); |
181 | foreach (Scene m_scene in m_scenes) | 181 | foreach (Scene m_scene in m_scenes) |
182 | { | 182 | { |
183 | m_scene.Broadcast(delegate(IClientAPI client) | 183 | m_scene.Broadcast(delegate(IClientAPI client) |
184 | { | 184 | { |
185 | client.SendChatMessage( | 185 | client.SendChatMessage( |
186 | Helpers.StringToField(mess), 255, pos, "IRC:", | 186 | Helpers.StringToField(mess), 255, pos, "IRC:", |
187 | LLUUID.Zero); | 187 | LLUUID.Zero); |
188 | }); | 188 | }); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | Thread.Sleep(50); | 192 | Thread.Sleep(50); |
193 | } | 193 | } |
194 | } | 194 | } |
@@ -205,7 +205,7 @@ namespace OpenSim.Region.Environment.Modules | |||
205 | scene = m_scenes[0]; | 205 | scene = m_scenes[0]; |
206 | 206 | ||
207 | // Filled in since it's easier than rewriting right now. | 207 | // Filled in since it's easier than rewriting right now. |
208 | LLVector3 fromPos = e.Position; | 208 | LLVector3 fromPos = e.Position; |
209 | LLVector3 fromRegionPos = e.Position + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0); | 209 | LLVector3 fromRegionPos = e.Position + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0); |
210 | string fromName = e.From; | 210 | string fromName = e.From; |
211 | string message = e.Message; | 211 | string message = e.Message; |
@@ -217,108 +217,108 @@ namespace OpenSim.Region.Environment.Modules | |||
217 | 217 | ||
218 | if (avatar != null) | 218 | if (avatar != null) |
219 | { | 219 | { |
220 | fromPos = avatar.AbsolutePosition; | 220 | fromPos = avatar.AbsolutePosition; |
221 | fromRegionPos = fromPos + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0); | 221 | fromRegionPos = fromPos + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0); |
222 | fromName = avatar.Firstname + " " + avatar.Lastname; | 222 | fromName = avatar.Firstname + " " + avatar.Lastname; |
223 | fromAgentID = e.Sender.AgentId; | 223 | fromAgentID = e.Sender.AgentId; |
224 | avatar = null; | 224 | avatar = null; |
225 | } | 225 | } |
226 | 226 | ||
227 | string typeName; | 227 | string typeName; |
228 | switch (e.Type) | 228 | switch (e.Type) |
229 | { | 229 | { |
230 | case ChatTypeEnum.Broadcast: | 230 | case ChatTypeEnum.Broadcast: |
231 | typeName = "broadcasts"; | 231 | typeName = "broadcasts"; |
232 | break; | 232 | break; |
233 | case ChatTypeEnum.Say: | 233 | case ChatTypeEnum.Say: |
234 | typeName = "says"; | 234 | typeName = "says"; |
235 | break; | 235 | break; |
236 | case ChatTypeEnum.Shout: | 236 | case ChatTypeEnum.Shout: |
237 | typeName = "shouts"; | 237 | typeName = "shouts"; |
238 | break; | 238 | break; |
239 | case ChatTypeEnum.Whisper: | 239 | case ChatTypeEnum.Whisper: |
240 | typeName = "whispers"; | 240 | typeName = "whispers"; |
241 | break; | 241 | break; |
242 | default: | 242 | default: |
243 | typeName = "unknown"; | 243 | typeName = "unknown"; |
244 | break; | 244 | break; |
245 | } | 245 | } |
246 | 246 | ||
247 | m_log.Verbose("CHAT", fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + e.Message); | 247 | m_log.Verbose("CHAT", fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + e.Message); |
248 | 248 | ||
249 | if (connected) | 249 | if (connected) |
250 | { | 250 | { |
251 | try | 251 | try |
252 | { | 252 | { |
253 | m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + " in " + scene.RegionInfo.RegionName + ">: " + | 253 | m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + " in " + scene.RegionInfo.RegionName + ">: " + |
254 | e.Message); | 254 | e.Message); |
255 | m_ircWriter.Flush(); | 255 | m_ircWriter.Flush(); |
256 | } | 256 | } |
257 | catch (IOException) | 257 | catch (IOException) |
258 | { | 258 | { |
259 | m_log.Error("IRC","Disconnected from IRC server."); | 259 | m_log.Error("IRC","Disconnected from IRC server."); |
260 | listener.Abort(); | 260 | listener.Abort(); |
261 | pingSender.Abort(); | 261 | pingSender.Abort(); |
262 | connected = false; | 262 | connected = false; |
263 | } | ||
264 | } | ||
265 | |||
266 | if (e.Channel == 0) | ||
267 | { | ||
268 | foreach (Scene m_scene in m_scenes) | ||
269 | { | ||
270 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) | ||
271 | { | ||
272 | int dis = -100000; | ||
273 | |||
274 | LLVector3 avatarRegionPos = presence.AbsolutePosition + new LLVector3(scene.RegionInfo.RegionLocX * 256, scene.RegionInfo.RegionLocY * 256, 0); | ||
275 | dis = Math.Abs((int)avatarRegionPos.GetDistanceTo(fromRegionPos)); | ||
276 | |||
277 | switch (e.Type) | ||
278 | { | ||
279 | case ChatTypeEnum.Whisper: | ||
280 | if (dis < m_whisperdistance) | ||
281 | { | ||
282 | //should change so the message is sent through the avatar rather than direct to the ClientView | ||
283 | presence.ControllingClient.SendChatMessage(message, | ||
284 | type, | ||
285 | fromPos, | ||
286 | fromName, | ||
287 | fromAgentID); | ||
288 | } | ||
289 | break; | ||
290 | default: | ||
291 | case ChatTypeEnum.Say: | ||
292 | if (dis < m_saydistance) | ||
293 | { | ||
294 | //Console.WriteLine("sending chat"); | ||
295 | presence.ControllingClient.SendChatMessage(message, | ||
296 | type, | ||
297 | fromPos, | ||
298 | fromName, | ||
299 | fromAgentID); | ||
300 | } | ||
301 | break; | ||
302 | case ChatTypeEnum.Shout: | ||
303 | if (dis < m_shoutdistance) | ||
304 | { | ||
305 | presence.ControllingClient.SendChatMessage(message, | ||
306 | type, | ||
307 | fromPos, | ||
308 | fromName, | ||
309 | fromAgentID); | ||
310 | } | ||
311 | break; | ||
312 | |||
313 | case ChatTypeEnum.Broadcast: | ||
314 | presence.ControllingClient.SendChatMessage(message, type, | ||
315 | fromPos, | ||
316 | fromName, | ||
317 | fromAgentID); | ||
318 | break; | ||
319 | } | ||
320 | }); | ||
263 | } | 321 | } |
264 | } | ||
265 | |||
266 | if (e.Channel == 0) | ||
267 | { | ||
268 | foreach (Scene m_scene in m_scenes) | ||
269 | { | ||
270 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) | ||
271 | { | ||
272 | int dis = -100000; | ||
273 | |||
274 | LLVector3 avatarRegionPos = presence.AbsolutePosition + new LLVector3(scene.RegionInfo.RegionLocX * 256, scene.RegionInfo.RegionLocY * 256, 0); | ||
275 | dis = Math.Abs((int)avatarRegionPos.GetDistanceTo(fromRegionPos)); | ||
276 | |||
277 | switch (e.Type) | ||
278 | { | ||
279 | case ChatTypeEnum.Whisper: | ||
280 | if (dis < m_whisperdistance) | ||
281 | { | ||
282 | //should change so the message is sent through the avatar rather than direct to the ClientView | ||
283 | presence.ControllingClient.SendChatMessage(message, | ||
284 | type, | ||
285 | fromPos, | ||
286 | fromName, | ||
287 | fromAgentID); | ||
288 | } | ||
289 | break; | ||
290 | default: | ||
291 | case ChatTypeEnum.Say: | ||
292 | if (dis < m_saydistance) | ||
293 | { | ||
294 | //Console.WriteLine("sending chat"); | ||
295 | presence.ControllingClient.SendChatMessage(message, | ||
296 | type, | ||
297 | fromPos, | ||
298 | fromName, | ||
299 | fromAgentID); | ||
300 | } | ||
301 | break; | ||
302 | case ChatTypeEnum.Shout: | ||
303 | if (dis < m_shoutdistance) | ||
304 | { | ||
305 | presence.ControllingClient.SendChatMessage(message, | ||
306 | type, | ||
307 | fromPos, | ||
308 | fromName, | ||
309 | fromAgentID); | ||
310 | } | ||
311 | break; | ||
312 | |||
313 | case ChatTypeEnum.Broadcast: | ||
314 | presence.ControllingClient.SendChatMessage(message, type, | ||
315 | fromPos, | ||
316 | fromName, | ||
317 | fromAgentID); | ||
318 | break; | ||
319 | } | ||
320 | }); | ||
321 | } | ||
322 | } | 322 | } |
323 | } | 323 | } |
324 | } | 324 | } |
diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index c856d57..d32ac0b 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | using libsecondlife; | 29 | using libsecondlife; |
30 | using OpenSim.Region.Environment.LandManagement; | 30 | using OpenSim.Region.Environment.LandManagement; |
31 | using OpenSim.Region.Environment.Scenes; | 31 | using OpenSim.Region.Environment.Scenes; |
32 | 32 | ||
33 | namespace OpenSim.Region.Environment | 33 | namespace OpenSim.Region.Environment |
34 | { | 34 | { |