aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorSean Dague2007-10-19 21:36:58 +0000
committerSean Dague2007-10-19 21:36:58 +0000
commit9a17bc58a6b97cab8f3e96e7bd3802ca761dfe52 (patch)
tree1e3b69a6b69ffa86efe893b4acfee87997905936 /OpenSim/Region
parentget rid of all the ^M line endings (diff)
downloadopensim-SC_OLD-9a17bc58a6b97cab8f3e96e7bd3802ca761dfe52.zip
opensim-SC_OLD-9a17bc58a6b97cab8f3e96e7bd3802ca761dfe52.tar.gz
opensim-SC_OLD-9a17bc58a6b97cab8f3e96e7bd3802ca761dfe52.tar.bz2
opensim-SC_OLD-9a17bc58a6b97cab8f3e96e7bd3802ca761dfe52.tar.xz
enable IRC bridge via runtime configuration
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Environment/Modules/ChatModule.cs85
1 files changed, 49 insertions, 36 deletions
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs
index a85a12c..7db4f4b 100644
--- a/OpenSim/Region/Environment/Modules/ChatModule.cs
+++ b/OpenSim/Region/Environment/Modules/ChatModule.cs
@@ -43,21 +43,21 @@ namespace OpenSim.Region.Environment.Modules
43 { 43 {
44 private Scene m_scene; 44 private Scene m_scene;
45 45
46 private string m_server = "irc2.choopa.net"; 46 private string m_server = null;
47 private int m_port = 6668;
48 private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
49 private string m_nick = null;
50 private string m_channel = null;
47 51
48 // private int m_port = 6668; 52 private NetworkStream m_stream;
49 //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
50 private string m_nick = "OSimBot";
51 private string m_channel = "#opensim";
52
53 // private NetworkStream m_stream;
54 private TcpClient m_irc; 53 private TcpClient m_irc;
55 private StreamWriter m_ircWriter; 54 private StreamWriter m_ircWriter;
56 private StreamReader m_ircReader; 55 private StreamReader m_ircReader;
56
57 private Thread pingSender;
58 private Thread listener;
57 59
58 // private Thread pingSender; 60 private bool m_enable_irc = false;
59 // private Thread listener;
60
61 private bool connected = false; 61 private bool connected = false;
62 62
63 public ChatModule() 63 public ChatModule()
@@ -70,6 +70,19 @@ namespace OpenSim.Region.Environment.Modules
70 70
71 public void Initialise(Scene scene, IConfigSource config) 71 public void Initialise(Scene scene, IConfigSource config)
72 { 72 {
73 try {
74 m_server = config.Configs["IRC"].GetString("server");
75 m_nick = config.Configs["IRC"].GetString("nick");
76 m_channel = config.Configs["IRC"].GetString("channel");
77 m_port = config.Configs["IRC"].GetInt("port", m_port);
78 m_user = config.Configs["IRC"].GetString("username", m_user);
79 if (m_server != null && m_nick != null && m_channel != null) {
80 m_enable_irc = true;
81 }
82 } catch (Exception e) {
83 Console.WriteLine("No IRC config information, skipping IRC bridge configuration");
84 }
85
73 m_scene = scene; 86 m_scene = scene;
74 m_scene.EventManager.OnNewClient += NewClient; 87 m_scene.EventManager.OnNewClient += NewClient;
75 88
@@ -78,33 +91,33 @@ namespace OpenSim.Region.Environment.Modules
78 91
79 public void PostInitialise() 92 public void PostInitialise()
80 { 93 {
81 /* 94 if( m_enable_irc ) {
82 try 95 try
83 { 96 {
84 m_irc = new TcpClient(m_server, m_port); 97 m_irc = new TcpClient(m_server, m_port);
85 m_stream = m_irc.GetStream(); 98 m_stream = m_irc.GetStream();
86 m_ircReader = new StreamReader(m_stream); 99 m_ircReader = new StreamReader(m_stream);
87 m_ircWriter = new StreamWriter(m_stream); 100 m_ircWriter = new StreamWriter(m_stream);
88 101
89 pingSender = new Thread(new ThreadStart(this.PingRun)); 102 pingSender = new Thread(new ThreadStart(this.PingRun));
90 pingSender.Start(); 103 pingSender.Start();
91 104
92 listener = new Thread(new ThreadStart(this.ListenerRun)); 105 listener = new Thread(new ThreadStart(this.ListenerRun));
93 listener.Start(); 106 listener.Start();
94 107
95 m_ircWriter.WriteLine(m_user); 108 m_ircWriter.WriteLine(m_user);
96 m_ircWriter.Flush(); 109 m_ircWriter.Flush();
97 m_ircWriter.WriteLine("NICK " + m_nick); 110 m_ircWriter.WriteLine("NICK " + m_nick);
98 m_ircWriter.Flush(); 111 m_ircWriter.Flush();
99 m_ircWriter.WriteLine("JOIN " + m_channel); 112 m_ircWriter.WriteLine("JOIN " + m_channel);
100 m_ircWriter.Flush(); 113 m_ircWriter.Flush();
101 connected = true; 114 connected = true;
102 } 115 }
103 catch (Exception e) 116 catch (Exception e)
104 { 117 {
105 Console.WriteLine(e.ToString()); 118 Console.WriteLine(e.ToString());
119 }
106 } 120 }
107 */
108 } 121 }
109 122
110 public void Close() 123 public void Close()