IRCBridgeModule: optional agent-alertbox for IRC enabled Regions look in OpenSimDefaults.ini / section [IRC]
http://opensimulator.org/mantis/view.php?id=6470 idea: https://github.com/ssm2017/IrcBridgeAlertuser_profiles
parent
41ae006e9b
commit
9c590e51b6
|
@ -46,7 +46,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
internal static bool m_pluginEnabled = false;
|
||||
internal static bool Enabled = false;
|
||||
internal static IConfig m_config = null;
|
||||
|
||||
internal static List<ChannelState> m_channels = new List<ChannelState>();
|
||||
|
@ -87,19 +87,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
m_password = config.Configs["RemoteAdmin"].GetString("access_password", m_password);
|
||||
}
|
||||
|
||||
m_pluginEnabled = true;
|
||||
m_log.InfoFormat("[IRC-Bridge]: Module enabled");
|
||||
Enabled = true;
|
||||
|
||||
m_log.InfoFormat("[IRC-Bridge]: Module is enabled");
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (m_pluginEnabled)
|
||||
if (Enabled)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_log.InfoFormat("[IRC-Bridge] Connecting region {0}", scene.RegionInfo.RegionName);
|
||||
|
||||
if (!String.IsNullOrEmpty(m_password))
|
||||
MainServer.Instance.AddXmlRPCHandler("irc_admin", XmlRpcAdminMethod, false);
|
||||
|
||||
m_region = new RegionState(scene, m_config);
|
||||
lock (m_regions) m_regions.Add(m_region);
|
||||
m_region.Open();
|
||||
|
@ -123,7 +126,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (!m_pluginEnabled)
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
if (m_region == null)
|
||||
|
|
|
@ -300,10 +300,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
|
||||
m_connected = false;
|
||||
|
||||
try { m_writer.Close(); } catch (Exception) {}
|
||||
try { m_reader.Close(); } catch (Exception) {}
|
||||
try { m_stream.Close(); } catch (Exception) {}
|
||||
try { m_tcp.Close(); } catch (Exception) {}
|
||||
try { m_writer.Close(); }
|
||||
catch (Exception) { }
|
||||
try { m_reader.Close(); }
|
||||
catch (Exception) { }
|
||||
try { m_stream.Close(); }
|
||||
catch (Exception) { }
|
||||
try { m_tcp.Close(); }
|
||||
catch (Exception) { }
|
||||
|
||||
}
|
||||
|
||||
|
@ -418,9 +422,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
// the socket and it will disappear of its own accord, once this
|
||||
// processing is completed.
|
||||
|
||||
try { m_writer.Close(); } catch (Exception) {}
|
||||
try { m_reader.Close(); } catch (Exception) {}
|
||||
try { m_tcp.Close(); } catch (Exception) {}
|
||||
try { m_writer.Close(); }
|
||||
catch (Exception) { }
|
||||
try { m_reader.Close(); }
|
||||
catch (Exception) { }
|
||||
try { m_tcp.Close(); }
|
||||
catch (Exception) { }
|
||||
|
||||
m_connected = false;
|
||||
m_pending = false;
|
||||
|
|
|
@ -41,7 +41,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
|
||||
internal class RegionState
|
||||
{
|
||||
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
@ -66,6 +65,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
internal IConfig config = null; // configuration file reference
|
||||
internal bool enabled = true;
|
||||
|
||||
//AgentAlert
|
||||
internal bool showAlert = false;
|
||||
internal string alertMessage = String.Empty;
|
||||
internal IDialogModule dialogModule = null;
|
||||
|
||||
// This list is used to keep track of who is here, and by
|
||||
// implication, who is not.
|
||||
|
||||
|
@ -75,7 +79,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
|
||||
public RegionState(Scene p_scene, IConfig p_config)
|
||||
{
|
||||
|
||||
scene = p_scene;
|
||||
config = p_config;
|
||||
|
||||
|
@ -85,6 +88,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
LocY = Convert.ToString(scene.RegionInfo.RegionLocY);
|
||||
IDK = Convert.ToString(_idk_++);
|
||||
|
||||
showAlert = config.GetBoolean("alert_show", false);
|
||||
string alertServerInfo = String.Empty;
|
||||
|
||||
if (showAlert)
|
||||
{
|
||||
bool showAlertServerInfo = config.GetBoolean("alert_show_serverinfo", true);
|
||||
|
||||
if (showAlertServerInfo)
|
||||
alertServerInfo = String.Format("\nServer: {0}\nPort: {1}\nChannel: {2}\n\n",
|
||||
config.GetString("server", ""), config.GetString("port", ""), config.GetString("channel", ""));
|
||||
|
||||
string alertPreMessage = config.GetString("alert_msg_pre", "This region is linked to Irc.");
|
||||
string alertPostMessage = config.GetString("alert_msg_post", "Everything you say in public chat can be listened.");
|
||||
|
||||
alertMessage = String.Format("{0}\n{1}{2}", alertPreMessage, alertServerInfo, alertPostMessage);
|
||||
|
||||
dialogModule = scene.RequestModuleInterface<IDialogModule>();
|
||||
}
|
||||
|
||||
// OpenChannel conditionally establishes a connection to the
|
||||
// IRC server. The request will either succeed, or it will
|
||||
// throw an exception.
|
||||
|
@ -195,7 +217,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
|
||||
private void OnMakeRootAgent(ScenePresence presence)
|
||||
{
|
||||
|
||||
IClientAPI client = presence.ControllingClient;
|
||||
|
||||
try
|
||||
|
@ -216,17 +237,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dialogModule != null && showAlert)
|
||||
dialogModule.SendAlertToUser(client, alertMessage, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.ErrorFormat("[IRC-Region {0}]: MakeRootAgent exception: {1}", Region, ex.Message);
|
||||
m_log.Debug(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// This handler detects chat events int he virtual world.
|
||||
|
||||
public void OnSimChat(Object sender, OSChatMessage msg)
|
||||
{
|
||||
|
||||
|
|
|
@ -1109,6 +1109,17 @@
|
|||
|
||||
;exclude_list=User 1,User 2,User 3
|
||||
|
||||
;;Shows modal alertbox for entering agent on IRC enabled regions
|
||||
;;
|
||||
;; Enable Alert, default = false
|
||||
;alert_show = false
|
||||
;;
|
||||
;; Show IRC serverinfo, default = true
|
||||
;alert_show_serverinfo = true
|
||||
;;
|
||||
;alert_msg_pre = "This region is linked to Irc."
|
||||
;alert_msg_post = "Everything you say in public chat can be listened."
|
||||
|
||||
|
||||
; The following settings control the progression of daytime
|
||||
; in the Sim. The defaults are the same as the commented out settings
|
||||
|
|
Loading…
Reference in New Issue