diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs index 7a3eadf..f9089cb 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs | |||
@@ -50,6 +50,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
50 | 50 | ||
51 | private static Regex arg = new Regex(@"\[[^\[\]]*\]"); | 51 | private static Regex arg = new Regex(@"\[[^\[\]]*\]"); |
52 | private static int _idk_ = 0; | 52 | private static int _idk_ = 0; |
53 | private static int DEBUG_CHANNEL = 2147483647; | ||
53 | 54 | ||
54 | // These are the IRC Connector configurable parameters with hard-wired | 55 | // These are the IRC Connector configurable parameters with hard-wired |
55 | // default values (retained for compatability). | 56 | // default values (retained for compatability). |
@@ -61,8 +62,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
61 | internal string User = "USER OpenSimBot 8 * :I'm an OpenSim to IRC bot"; | 62 | internal string User = "USER OpenSimBot 8 * :I'm an OpenSim to IRC bot"; |
62 | 63 | ||
63 | internal bool ClientReporting = true; | 64 | internal bool ClientReporting = true; |
65 | internal bool RelayChat = true; | ||
64 | internal bool RelayPrivateChannels = false; | 66 | internal bool RelayPrivateChannels = false; |
65 | internal int RelayChannel = 1; | 67 | internal int RelayChannel = 1; |
68 | internal List<int> ValidInWorldChannels = new List<int>(); | ||
66 | 69 | ||
67 | // Connector agnostic parameters. These values are NOT shared with the | 70 | // Connector agnostic parameters. These values are NOT shared with the |
68 | // connector and do not differentiate at an IRC level | 71 | // connector and do not differentiate at an IRC level |
@@ -71,13 +74,27 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
71 | internal string NoticeMessageFormat = "PRIVMSG {0} :<{2}> {3}"; | 74 | internal string NoticeMessageFormat = "PRIVMSG {0} :<{2}> {3}"; |
72 | internal int RelayChannelOut = -1; | 75 | internal int RelayChannelOut = -1; |
73 | internal bool RandomizeNickname = true; | 76 | internal bool RandomizeNickname = true; |
74 | internal string AccessPassword = "badkitty"; | ||
75 | internal bool CommandsEnabled = false; | 77 | internal bool CommandsEnabled = false; |
76 | internal int CommandChannel = -1; | 78 | internal int CommandChannel = -1; |
77 | internal int ConnectDelay = 10; | 79 | internal int ConnectDelay = 10; |
78 | internal int PingDelay = 15; | 80 | internal int PingDelay = 15; |
79 | internal string DefaultZone = "Sim"; | 81 | internal string DefaultZone = "Sim"; |
80 | 82 | ||
83 | internal string _accessPassword = String.Empty; | ||
84 | internal Regex AccessPasswordRegex = null; | ||
85 | internal string AccessPassword | ||
86 | { | ||
87 | get { return _accessPassword; } | ||
88 | set | ||
89 | { | ||
90 | _accessPassword = value; | ||
91 | AccessPasswordRegex = new Regex(String.Format(@"^{0},\s*(?<avatar>[^,]+),\s*(?<message>.+)$", _accessPassword), | ||
92 | RegexOptions.Compiled); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | |||
97 | |||
81 | // IRC connector reference | 98 | // IRC connector reference |
82 | 99 | ||
83 | internal XIRCConnector irc = null; | 100 | internal XIRCConnector irc = null; |
@@ -108,9 +125,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
108 | User = model.User; | 125 | User = model.User; |
109 | CommandsEnabled = model.CommandsEnabled; | 126 | CommandsEnabled = model.CommandsEnabled; |
110 | CommandChannel = model.CommandChannel; | 127 | CommandChannel = model.CommandChannel; |
128 | RelayChat = model.RelayChat; | ||
111 | RelayPrivateChannels = model.RelayPrivateChannels; | 129 | RelayPrivateChannels = model.RelayPrivateChannels; |
112 | RelayChannelOut = model.RelayChannelOut; | 130 | RelayChannelOut = model.RelayChannelOut; |
113 | RelayChannel = model.RelayChannel; | 131 | RelayChannel = model.RelayChannel; |
132 | ValidInWorldChannels = model.ValidInWorldChannels; | ||
114 | PrivateMessageFormat = model.PrivateMessageFormat; | 133 | PrivateMessageFormat = model.PrivateMessageFormat; |
115 | NoticeMessageFormat = model.NoticeMessageFormat; | 134 | NoticeMessageFormat = model.NoticeMessageFormat; |
116 | ClientReporting = model.ClientReporting; | 135 | ClientReporting = model.ClientReporting; |
@@ -158,6 +177,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
158 | m_log.DebugFormat("[IRC-Channel-{0}] CommandChannel : <{1}>", cs.idn, cs.CommandChannel); | 177 | m_log.DebugFormat("[IRC-Channel-{0}] CommandChannel : <{1}>", cs.idn, cs.CommandChannel); |
159 | cs.CommandChannel = Convert.ToInt32(Substitute(rs, config.GetString("command_channel", Convert.ToString(cs.CommandChannel)))); | 178 | cs.CommandChannel = Convert.ToInt32(Substitute(rs, config.GetString("command_channel", Convert.ToString(cs.CommandChannel)))); |
160 | m_log.DebugFormat("[IRC-Channel-{0}] CommandChannel : <{1}>", cs.idn, cs.CommandChannel); | 179 | m_log.DebugFormat("[IRC-Channel-{0}] CommandChannel : <{1}>", cs.idn, cs.CommandChannel); |
180 | cs.RelayChat = Convert.ToBoolean(Substitute(rs, config.GetString("relay_chat", Convert.ToString(cs.RelayChat)))); | ||
181 | m_log.DebugFormat("[IRC-Channel-{0}] RelayChat : <{1}>", cs.idn, cs.RelayChat); | ||
161 | cs.RelayPrivateChannels = Convert.ToBoolean(Substitute(rs, config.GetString("relay_private_channels", Convert.ToString(cs.RelayPrivateChannels)))); | 182 | cs.RelayPrivateChannels = Convert.ToBoolean(Substitute(rs, config.GetString("relay_private_channels", Convert.ToString(cs.RelayPrivateChannels)))); |
162 | m_log.DebugFormat("[IRC-Channel-{0}] RelayPrivateChannels : <{1}>", cs.idn, cs.RelayPrivateChannels); | 183 | m_log.DebugFormat("[IRC-Channel-{0}] RelayPrivateChannels : <{1}>", cs.idn, cs.RelayPrivateChannels); |
163 | cs.RelayPrivateChannels = Convert.ToBoolean(Substitute(rs, config.GetString("useworldcomm", Convert.ToString(cs.RelayPrivateChannels)))); | 184 | cs.RelayPrivateChannels = Convert.ToBoolean(Substitute(rs, config.GetString("useworldcomm", Convert.ToString(cs.RelayPrivateChannels)))); |
@@ -176,14 +197,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
176 | m_log.DebugFormat("[IRC-Channel-{0}] ClientReporting : <{1}>", cs.idn, cs.ClientReporting); | 197 | m_log.DebugFormat("[IRC-Channel-{0}] ClientReporting : <{1}>", cs.idn, cs.ClientReporting); |
177 | cs.ClientReporting = Convert.ToBoolean(Substitute(rs, config.GetString("report_clients", Convert.ToString(cs.ClientReporting)))); | 198 | cs.ClientReporting = Convert.ToBoolean(Substitute(rs, config.GetString("report_clients", Convert.ToString(cs.ClientReporting)))); |
178 | m_log.DebugFormat("[IRC-Channel-{0}] ClientReporting : <{1}>", cs.idn, cs.ClientReporting); | 199 | m_log.DebugFormat("[IRC-Channel-{0}] ClientReporting : <{1}>", cs.idn, cs.ClientReporting); |
179 | cs.AccessPassword = Substitute(rs, config.GetString("access_password", cs.AccessPassword)); | ||
180 | m_log.DebugFormat("[IRC-Channel-{0}] AccessPassword : <{1}>", cs.idn, cs.AccessPassword); | ||
181 | cs.DefaultZone = Substitute(rs, config.GetString("fallback_region", cs.DefaultZone)); | 200 | cs.DefaultZone = Substitute(rs, config.GetString("fallback_region", cs.DefaultZone)); |
182 | m_log.DebugFormat("[IRC-Channel-{0}] DefaultZone : <{1}>", cs.idn, cs.DefaultZone); | 201 | m_log.DebugFormat("[IRC-Channel-{0}] DefaultZone : <{1}>", cs.idn, cs.DefaultZone); |
183 | cs.ConnectDelay = Convert.ToInt32(Substitute(rs, config.GetString("connect_delay", Convert.ToString(cs.ConnectDelay)))); | 202 | cs.ConnectDelay = Convert.ToInt32(Substitute(rs, config.GetString("connect_delay", Convert.ToString(cs.ConnectDelay)))); |
184 | m_log.DebugFormat("[IRC-Channel-{0}] ConnectDelay : <{1}>", cs.idn, cs.ConnectDelay); | 203 | m_log.DebugFormat("[IRC-Channel-{0}] ConnectDelay : <{1}>", cs.idn, cs.ConnectDelay); |
185 | cs.PingDelay = Convert.ToInt32(Substitute(rs, config.GetString("ping_delay", Convert.ToString(cs.PingDelay)))); | 204 | cs.PingDelay = Convert.ToInt32(Substitute(rs, config.GetString("ping_delay", Convert.ToString(cs.PingDelay)))); |
186 | m_log.DebugFormat("[IRC-Channel-{0}] PingDelay : <{1}>", cs.idn, cs.PingDelay); | 205 | m_log.DebugFormat("[IRC-Channel-{0}] PingDelay : <{1}>", cs.idn, cs.PingDelay); |
206 | cs.AccessPassword = Substitute(rs, config.GetString("access_password", cs.AccessPassword)); | ||
207 | m_log.DebugFormat("[IRC-Channel-{0}] AccessPassword : <{1}>", cs.idn, cs.AccessPassword); | ||
208 | |||
187 | 209 | ||
188 | // Fail if fundamental information is still missing | 210 | // Fail if fundamental information is still missing |
189 | 211 | ||
@@ -199,6 +221,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
199 | 221 | ||
200 | // Set the channel state for this region | 222 | // Set the channel state for this region |
201 | 223 | ||
224 | if (cs.RelayChat) | ||
225 | { | ||
226 | cs.ValidInWorldChannels.Add(0); | ||
227 | cs.ValidInWorldChannels.Add(DEBUG_CHANNEL); | ||
228 | } | ||
229 | |||
230 | if (cs.RelayPrivateChannels) | ||
231 | cs.ValidInWorldChannels.Add(cs.RelayChannelOut); | ||
232 | |||
202 | rs.cs = Integrate(rs, cs); | 233 | rs.cs = Integrate(rs, cs); |
203 | 234 | ||
204 | } | 235 | } |
@@ -377,18 +408,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
377 | private bool IsAPerfectMatchFor(ChannelState cs) | 408 | private bool IsAPerfectMatchFor(ChannelState cs) |
378 | { | 409 | { |
379 | return ( IsAConnectionMatchFor(cs) && | 410 | return ( IsAConnectionMatchFor(cs) && |
380 | 411 | RelayChannelOut == cs.RelayChannelOut && | |
381 | RelayChannelOut == cs.RelayChannelOut && | 412 | PrivateMessageFormat == cs.PrivateMessageFormat && |
382 | PrivateMessageFormat == cs.PrivateMessageFormat && | 413 | NoticeMessageFormat == cs.NoticeMessageFormat && |
383 | NoticeMessageFormat == cs.NoticeMessageFormat && | 414 | RandomizeNickname == cs.RandomizeNickname && |
384 | RandomizeNickname == cs.RandomizeNickname && | 415 | AccessPassword == cs.AccessPassword && |
385 | AccessPassword == cs.AccessPassword && | 416 | CommandsEnabled == cs.CommandsEnabled && |
386 | CommandsEnabled == cs.CommandsEnabled && | 417 | CommandChannel == cs.CommandChannel && |
387 | CommandChannel == cs.CommandChannel && | 418 | DefaultZone == cs.DefaultZone && |
388 | DefaultZone == cs.DefaultZone && | 419 | RelayPrivateChannels == cs.RelayPrivateChannels && |
389 | RelayPrivateChannels == cs.RelayPrivateChannels && | 420 | RelayChannel == cs.RelayChannel && |
390 | RelayChannel == cs.RelayChannel && | 421 | RelayChat == cs.RelayChat && |
391 | ClientReporting == cs.ClientReporting | 422 | ClientReporting == cs.ClientReporting |
392 | ); | 423 | ); |
393 | } | 424 | } |
394 | 425 | ||