diff options
author | Sean Dague | 2007-10-22 16:35:39 +0000 |
---|---|---|
committer | Sean Dague | 2007-10-22 16:35:39 +0000 |
commit | 8e424a41623cb20fc22572ef19da65fd5b80e7fc (patch) | |
tree | 64bd5c60b1acafea19c826809c1011551c3836fe /OpenSim/Region | |
parent | make IRC uglier for a while to get a better handle on writing a parser for th... (diff) | |
download | opensim-SC-8e424a41623cb20fc22572ef19da65fd5b80e7fc.zip opensim-SC-8e424a41623cb20fc22572ef19da65fd5b80e7fc.tar.gz opensim-SC-8e424a41623cb20fc22572ef19da65fd5b80e7fc.tar.bz2 opensim-SC-8e424a41623cb20fc22572ef19da65fd5b80e7fc.tar.xz |
make for nicer IRC messages. No promiss that this works yet, but
it is a first attempt. Will tune shortly.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Environment/Modules/ChatModule.cs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 54f32f6..5a31e0b 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs | |||
@@ -31,6 +31,7 @@ using System.IO; | |||
31 | using System.Net.Sockets; | 31 | using System.Net.Sockets; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | using System.Collections.Generic; | 33 | using System.Collections.Generic; |
34 | using System.Text.RegularExpressions; | ||
34 | using libsecondlife; | 35 | using libsecondlife; |
35 | using OpenSim.Framework.Interfaces; | 36 | using OpenSim.Framework.Interfaces; |
36 | using OpenSim.Framework.Utilities; | 37 | using OpenSim.Framework.Utilities; |
@@ -319,6 +320,23 @@ namespace OpenSim.Region.Environment.Modules | |||
319 | } | 320 | } |
320 | } | 321 | } |
321 | 322 | ||
323 | private Dictionary<string, string> ExtractMsg(string input) { | ||
324 | Dictionary<string, string> result = null; | ||
325 | string regex = @":(?<nick>\w*)!~(?<user>\S*) PRIVMSG (?<channel>\S+) :(?<msg>.*)"; | ||
326 | Regex RE = new Regex(regex, RegexOptions.Multiline); | ||
327 | MatchCollection matches = RE.Matches(input); | ||
328 | // Get some direct matches $1 $4 is a | ||
329 | if (matches.Count == 4) { | ||
330 | result = new Dictionary<string, string>(); | ||
331 | result.Add("nick", matches[0].Value); | ||
332 | result.Add("user", matches[1].Value); | ||
333 | result.Add("channel", matches[2].Value); | ||
334 | result.Add("msg", matches[3].Value); | ||
335 | } else { | ||
336 | m_log.Verbose("IRC", "Number of matches: " + matches.Count); | ||
337 | } | ||
338 | return result; | ||
339 | } | ||
322 | 340 | ||
323 | public void PingRun() | 341 | public void PingRun() |
324 | { | 342 | { |
@@ -341,18 +359,21 @@ namespace OpenSim.Region.Environment.Modules | |||
341 | Console.WriteLine(inputLine); | 359 | Console.WriteLine(inputLine); |
342 | if (inputLine.Contains(m_channel)) | 360 | if (inputLine.Contains(m_channel)) |
343 | { | 361 | { |
344 | string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); | 362 | Dictionary<string, string> data = ExtractMsg(inputLine); |
345 | foreach (Scene m_scene in m_scenes) | 363 | if (data != null ) |
346 | { | 364 | { |
347 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) | 365 | foreach (Scene m_scene in m_scenes) |
366 | { | ||
367 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) | ||
348 | { | 368 | { |
349 | if (!avatar.IsChildAgent) | 369 | if (!avatar.IsChildAgent) |
350 | { | 370 | { |
351 | avatar.ControllingClient.SendChatMessage( | 371 | avatar.ControllingClient.SendChatMessage( |
352 | Helpers.StringToField(inputLine), 255, pos, "IRC:", | 372 | Helpers.StringToField(data["msg"]), 255, pos, data["nick"], |
353 | LLUUID.Zero); | 373 | LLUUID.Zero); |
354 | } | 374 | } |
355 | }); | 375 | }); |
376 | } | ||
356 | } | 377 | } |
357 | } | 378 | } |
358 | } | 379 | } |