enable IRC bridge via runtime configuration

afrisby
Sean Dague 2007-10-19 21:36:58 +00:00
parent d4bb430f78
commit 9a17bc58a6
2 changed files with 56 additions and 36 deletions

View File

@ -43,21 +43,21 @@ namespace OpenSim.Region.Environment.Modules
{
private Scene m_scene;
private string m_server = "irc2.choopa.net";
private string m_server = null;
private int m_port = 6668;
private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
private string m_nick = null;
private string m_channel = null;
// private int m_port = 6668;
//private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
private string m_nick = "OSimBot";
private string m_channel = "#opensim";
// private NetworkStream m_stream;
private NetworkStream m_stream;
private TcpClient m_irc;
private StreamWriter m_ircWriter;
private StreamReader m_ircReader;
// private Thread pingSender;
// private Thread listener;
private Thread pingSender;
private Thread listener;
private bool m_enable_irc = false;
private bool connected = false;
public ChatModule()
@ -70,6 +70,19 @@ namespace OpenSim.Region.Environment.Modules
public void Initialise(Scene scene, IConfigSource config)
{
try {
m_server = config.Configs["IRC"].GetString("server");
m_nick = config.Configs["IRC"].GetString("nick");
m_channel = config.Configs["IRC"].GetString("channel");
m_port = config.Configs["IRC"].GetInt("port", m_port);
m_user = config.Configs["IRC"].GetString("username", m_user);
if (m_server != null && m_nick != null && m_channel != null) {
m_enable_irc = true;
}
} catch (Exception e) {
Console.WriteLine("No IRC config information, skipping IRC bridge configuration");
}
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;
@ -78,7 +91,7 @@ namespace OpenSim.Region.Environment.Modules
public void PostInitialise()
{
/*
if( m_enable_irc ) {
try
{
m_irc = new TcpClient(m_server, m_port);
@ -104,7 +117,7 @@ namespace OpenSim.Region.Environment.Modules
{
Console.WriteLine(e.ToString());
}
*/
}
}
public void Close()

View File

@ -39,4 +39,11 @@ user_recv_key = "null"
asset_server_url = "http://127.0.0.1:8003"
; Uncomment the following for IRC bridge
; experimental, so if it breaks... keep both parts... yada yada
; also, not good error detection when it fails
;[IRC]
;server = name.of.irc.server.on.the.net
;nick = OpenSimBotNameProbablyMakeThisShorter
;channel = #the_irc_channel_you_want_to_connect_to