Added an optional password for the IRC module

0.6.3-post-fixes
Dahlia Trimble 2009-01-18 10:50:53 +00:00
parent 1d8821ccb2
commit 37b63636ee
3 changed files with 15 additions and 1 deletions

View File

@ -56,6 +56,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
// default values (retained for compatability).
internal string Server = null;
internal string Password = null;
internal string IrcChannel = null;
internal string BaseNickname = "OSimBot";
internal uint Port = 6667;
@ -118,6 +119,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
internal ChannelState(ChannelState model)
{
Server = model.Server;
Password = model.Password;
IrcChannel = model.IrcChannel;
Port = model.Port;
BaseNickname = model.BaseNickname;
@ -159,6 +161,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
cs.Server = Substitute(rs, config.GetString("server", null));
m_log.DebugFormat("[IRC-Channel-{0}] Server : <{1}>", cs.idn, cs.Server);
cs.Password = Substitute(rs, config.GetString("password", null));
// probably not a good idea to put a password in the log file
cs.IrcChannel = Substitute(rs, config.GetString("channel", null));
m_log.DebugFormat("[IRC-Channel-{0}] IrcChannel : <{1}>", cs.idn, cs.IrcChannel);
cs.Port = Convert.ToUInt32(Substitute(rs, config.GetString("port", Convert.ToString(cs.Port))));

View File

@ -146,6 +146,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
get { return m_server; }
set { m_server = value; }
}
private string m_password = null;
public string Password
{
get { return m_password; }
set { m_password = value; }
}
private string m_user = "USER OpenSimBot 8 * :I'm an OpenSim to IRC bot";
public string User
@ -183,6 +189,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
// Setup IRC session parameters
m_server = cs.Server;
m_password = cs.Password;
m_baseNick = cs.BaseNickname;
m_randomizeNick = cs.RandomizeNickname;
m_ircChannel = cs.IrcChannel;
@ -346,7 +353,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
ThreadTracker.Add(m_listener);
// This is the message order recommended by RFC 2812
if (m_password != null)
m_writer.WriteLine(String.Format("PASS {0}", m_password));
m_writer.WriteLine(String.Format("NICK {0}", m_nick));
m_writer.Flush();
m_writer.WriteLine(m_user);

View File

@ -512,6 +512,8 @@ InterregionComms = "RESTComms"
;[IRC]
;enabled = true ; you need to set this otherwise it won't connect
;server = name.of.irc.server.on.the.net
;; user password - only use this if the server requires one
;password = mypass
;nick = OpenSimBotNameProbablyMakeThisShorter
;channel = #the_irc_channel_you_want_to_connect_to
;port = 6667