diff options
author | MW | 2007-08-29 19:09:45 +0000 |
---|---|---|
committer | MW | 2007-08-29 19:09:45 +0000 |
commit | a7f7dfc0dc5584215c2457cc28e96e39b5e9857b (patch) | |
tree | f4537aff18487d6bba76131181657df3bde03f92 /OpenSim/Region/Environment/Modules/ChatModule.cs | |
parent | Remove a debug line. (diff) | |
download | opensim-SC-a7f7dfc0dc5584215c2457cc28e96e39b5e9857b.zip opensim-SC-a7f7dfc0dc5584215c2457cc28e96e39b5e9857b.tar.gz opensim-SC-a7f7dfc0dc5584215c2457cc28e96e39b5e9857b.tar.bz2 opensim-SC-a7f7dfc0dc5584215c2457cc28e96e39b5e9857b.tar.xz |
few small changes (all work in progress).
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/ChatModule.cs | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 300269a..c26a1a5 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs | |||
@@ -13,15 +13,15 @@ using OpenSim.Framework.Utilities; | |||
13 | 13 | ||
14 | namespace OpenSim.Region.Environment.Modules | 14 | namespace OpenSim.Region.Environment.Modules |
15 | { | 15 | { |
16 | public class ChatModule :IRegionModule | 16 | public class ChatModule : IRegionModule |
17 | { | 17 | { |
18 | private Scene m_scene; | 18 | private Scene m_scene; |
19 | 19 | ||
20 | private string m_server = "irc2.choopa.net"; | 20 | private string m_server = "irc2.choopa.net"; |
21 | 21 | ||
22 | private int m_port = 6668; | 22 | private int m_port = 6668; |
23 | private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; | 23 | private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; |
24 | private string m_nick = "OpenSimBot"; | 24 | private string m_nick = "OSimBot"; |
25 | private string m_channel = "#opensim"; | 25 | private string m_channel = "#opensim"; |
26 | 26 | ||
27 | private NetworkStream m_stream; | 27 | private NetworkStream m_stream; |
@@ -30,12 +30,13 @@ namespace OpenSim.Region.Environment.Modules | |||
30 | private StreamReader m_ircReader; | 30 | private StreamReader m_ircReader; |
31 | 31 | ||
32 | private Thread pingSender; | 32 | private Thread pingSender; |
33 | private Thread listener; | ||
33 | 34 | ||
34 | private bool connected = false; | 35 | private bool connected = false; |
35 | 36 | ||
36 | public ChatModule() | 37 | public ChatModule() |
37 | { | 38 | { |
38 | 39 | m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); | |
39 | } | 40 | } |
40 | 41 | ||
41 | public void Initialise(Scene scene) | 42 | public void Initialise(Scene scene) |
@@ -58,6 +59,9 @@ namespace OpenSim.Region.Environment.Modules | |||
58 | pingSender = new Thread(new ThreadStart(this.PingRun)); | 59 | pingSender = new Thread(new ThreadStart(this.PingRun)); |
59 | pingSender.Start(); | 60 | pingSender.Start(); |
60 | 61 | ||
62 | listener = new Thread(new ThreadStart(this.ListenerRun)); | ||
63 | listener.Start(); | ||
64 | |||
61 | m_ircWriter.WriteLine(m_user); | 65 | m_ircWriter.WriteLine(m_user); |
62 | m_ircWriter.Flush(); | 66 | m_ircWriter.Flush(); |
63 | m_ircWriter.WriteLine("NICK " + m_nick); | 67 | m_ircWriter.WriteLine("NICK " + m_nick); |
@@ -99,6 +103,28 @@ namespace OpenSim.Region.Environment.Modules | |||
99 | } | 103 | } |
100 | } | 104 | } |
101 | 105 | ||
106 | public void ListenerRun() | ||
107 | { | ||
108 | string inputLine; | ||
109 | LLVector3 pos = new LLVector3(128, 128, 20); | ||
110 | while (true) | ||
111 | { | ||
112 | while ((inputLine = m_ircReader.ReadLine()) != null) | ||
113 | { | ||
114 | Console.WriteLine(inputLine); | ||
115 | if (inputLine.Contains(m_channel)) | ||
116 | { | ||
117 | string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); | ||
118 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) | ||
119 | { | ||
120 | presence.ControllingClient.SendChatMessage(Helpers.StringToField(mess), 255, pos, "IRC:", | ||
121 | LLUUID.Zero); | ||
122 | }); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | |||
102 | public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | 128 | public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) |
103 | { | 129 | { |
104 | ScenePresence avatar = null; | 130 | ScenePresence avatar = null; |
@@ -112,7 +138,7 @@ namespace OpenSim.Region.Environment.Modules | |||
112 | 138 | ||
113 | if (connected) | 139 | if (connected) |
114 | { | 140 | { |
115 | m_ircWriter.WriteLine("MSG " + m_channel +" :" + fromName + ", " + Util.FieldToString(message)); | 141 | m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + Util.FieldToString(message)); |
116 | m_ircWriter.Flush(); | 142 | m_ircWriter.Flush(); |
117 | } | 143 | } |
118 | 144 | ||