diff options
author | Dr Scofield | 2008-10-21 17:55:25 +0000 |
---|---|---|
committer | Dr Scofield | 2008-10-21 17:55:25 +0000 |
commit | 2a506f0cb2d2d5f10473cacd0dd8a9c7c04300e7 (patch) | |
tree | 1da04c4c6662bc83fa7dcf6bafbfaf24374ac03c | |
parent | cleanup. (diff) | |
download | opensim-SC_OLD-2a506f0cb2d2d5f10473cacd0dd8a9c7c04300e7.zip opensim-SC_OLD-2a506f0cb2d2d5f10473cacd0dd8a9c7c04300e7.tar.gz opensim-SC_OLD-2a506f0cb2d2d5f10473cacd0dd8a9c7c04300e7.tar.bz2 opensim-SC_OLD-2a506f0cb2d2d5f10473cacd0dd8a9c7c04300e7.tar.xz |
adding "welcome" support to Concierge: allows to specify via
welcomes = /path/to/welcome/files/directory
a directory in which you can place welcome templates for concierged
regions (those regions that match the "regions" regexp). you can use
format substitution:
0: will be replaced by avatar name of the avatar entering the region
1: will be replaced by region name
2: will be replaced the name of the concierge
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs | 68 |
1 files changed, 60 insertions, 8 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs index 6cc622e..ab60763 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs | |||
@@ -51,10 +51,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge | |||
51 | private int _conciergeChannel = 42; | 51 | private int _conciergeChannel = 42; |
52 | private List<IScene> _scenes = new List<IScene>(); | 52 | private List<IScene> _scenes = new List<IScene>(); |
53 | private List<IScene> _conciergedScenes = new List<IScene>(); | 53 | private List<IScene> _conciergedScenes = new List<IScene>(); |
54 | private Dictionary<IScene, List<string>> _sceneAttendees = new Dictionary<IScene, List<string>>(); | ||
54 | private IConfig _config; | 55 | private IConfig _config; |
55 | private string _whoami = "conferencier"; | 56 | private string _whoami = "conferencier"; |
56 | private bool _replacingChatModule = false; | 57 | private bool _replacingChatModule = false; |
57 | private Regex _regions = null; | 58 | private Regex _regions = null; |
59 | private string _welcomes = null; | ||
58 | 60 | ||
59 | internal object _syncy = new object(); | 61 | internal object _syncy = new object(); |
60 | 62 | ||
@@ -105,6 +107,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge | |||
105 | // take note of concierge channel and of identity | 107 | // take note of concierge channel and of identity |
106 | _conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", _conciergeChannel); | 108 | _conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", _conciergeChannel); |
107 | _whoami = _config.GetString("whoami", "conferencier"); | 109 | _whoami = _config.GetString("whoami", "conferencier"); |
110 | _welcomes = _config.GetString("welcomes", _welcomes); | ||
108 | _log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", _whoami); | 111 | _log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", _whoami); |
109 | 112 | ||
110 | // calculate regions Regex | 113 | // calculate regions Regex |
@@ -123,7 +126,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge | |||
123 | { | 126 | { |
124 | _scenes.Add(scene); | 127 | _scenes.Add(scene); |
125 | 128 | ||
126 | if (_regions.IsMatch(scene.RegionInfo.RegionName)) | 129 | if (_regions == null || _regions.IsMatch(scene.RegionInfo.RegionName)) |
127 | _conciergedScenes.Add(scene); | 130 | _conciergedScenes.Add(scene); |
128 | 131 | ||
129 | // subscribe to NewClient events | 132 | // subscribe to NewClient events |
@@ -181,13 +184,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge | |||
181 | { | 184 | { |
182 | if (_replacingChatModule) | 185 | if (_replacingChatModule) |
183 | { | 186 | { |
187 | // replacing ChatModule: need to redistribute | ||
188 | // ChatFromClient to interested subscribers | ||
189 | c = FixPositionOfChatMessage(c); | ||
190 | |||
191 | Scene scene = (Scene)c.Scene; | ||
192 | scene.EventManager.TriggerOnChatFromClient(sender, c); | ||
193 | |||
184 | if (_conciergedScenes.Contains(c.Scene)) | 194 | if (_conciergedScenes.Contains(c.Scene)) |
185 | { | 195 | { |
186 | // replacing ChatModule: need to redistribute | ||
187 | // ChatFromClient to interested subscribers | ||
188 | Scene scene = (Scene)c.Scene; | ||
189 | scene.EventManager.TriggerOnChatFromClient(sender, c); | ||
190 | |||
191 | // when we are replacing ChatModule, we treat | 196 | // when we are replacing ChatModule, we treat |
192 | // OnChatFromClient like OnChatBroadcast for | 197 | // OnChatFromClient like OnChatBroadcast for |
193 | // concierged regions, effectively extending the | 198 | // concierged regions, effectively extending the |
@@ -269,6 +274,37 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge | |||
269 | if (_conciergedScenes.Contains(agent.Scene)) | 274 | if (_conciergedScenes.Contains(agent.Scene)) |
270 | { | 275 | { |
271 | _log.DebugFormat("[Concierge] {0} enters {1}", agent.Name, agent.Scene.RegionInfo.RegionName); | 276 | _log.DebugFormat("[Concierge] {0} enters {1}", agent.Name, agent.Scene.RegionInfo.RegionName); |
277 | |||
278 | // welcome mechanics: check whether we have a welcomes | ||
279 | // directory set and wether there is a region specific | ||
280 | // welcome file there: if yes, send it to the agent | ||
281 | if (!String.IsNullOrEmpty(_welcomes)) | ||
282 | { | ||
283 | string welcome = Path.Combine(_welcomes, agent.Scene.RegionInfo.RegionName); | ||
284 | if (File.Exists(welcome)) | ||
285 | { | ||
286 | try | ||
287 | { | ||
288 | string[] welcomeLines = File.ReadAllLines(welcome); | ||
289 | foreach (string l in welcomeLines) | ||
290 | { | ||
291 | AnnounceToAgent(agent, String.Format(l, agent.Name, agent.Scene.RegionInfo.RegionName, _whoami)); | ||
292 | } | ||
293 | } | ||
294 | catch (IOException ioe) | ||
295 | { | ||
296 | _log.ErrorFormat("[Concierge] run into trouble reading welcome file {0} for region {1} for avatar {2}: {3}", | ||
297 | welcome, agent.Scene.RegionInfo.RegionName, agent.Name, ioe); | ||
298 | } | ||
299 | catch (FormatException fe) | ||
300 | { | ||
301 | _log.ErrorFormat("[Concierge] welcome file {0} is malformed: {1}", welcome, fe); | ||
302 | } | ||
303 | } else { | ||
304 | _log.DebugFormat("[Concierge] not playing out welcome message: {0} not found", welcome); | ||
305 | } | ||
306 | } | ||
307 | |||
272 | AnnounceToAgentsRegion(agent, String.Format("{0} enters {1}", agent.Name, | 308 | AnnounceToAgentsRegion(agent, String.Format("{0} enters {1}", agent.Name, |
273 | agent.Scene.RegionInfo.RegionName)); | 309 | agent.Scene.RegionInfo.RegionName)); |
274 | } | 310 | } |
@@ -295,7 +331,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge | |||
295 | } | 331 | } |
296 | } | 332 | } |
297 | 333 | ||
298 | static private Vector3 posOfGod = new Vector3(128, 128, 9999); | 334 | static private Vector3 PosOfGod = new Vector3(128, 128, 9999); |
299 | 335 | ||
300 | protected void AnnounceToAgentsRegion(IClientAPI client, string msg) | 336 | protected void AnnounceToAgentsRegion(IClientAPI client, string msg) |
301 | { | 337 | { |
@@ -312,7 +348,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge | |||
312 | c.Message = msg; | 348 | c.Message = msg; |
313 | c.Type = ChatTypeEnum.Say; | 349 | c.Type = ChatTypeEnum.Say; |
314 | c.Channel = 0; | 350 | c.Channel = 0; |
315 | c.Position = posOfGod; | 351 | c.Position = PosOfGod; |
316 | c.From = _whoami; | 352 | c.From = _whoami; |
317 | c.Sender = null; | 353 | c.Sender = null; |
318 | c.SenderUUID = UUID.Zero; | 354 | c.SenderUUID = UUID.Zero; |
@@ -320,5 +356,21 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge | |||
320 | 356 | ||
321 | scenePresence.Scene.EventManager.TriggerOnChatBroadcast(this, c); | 357 | scenePresence.Scene.EventManager.TriggerOnChatBroadcast(this, c); |
322 | } | 358 | } |
359 | |||
360 | protected void AnnounceToAgent(ScenePresence agent, string msg) | ||
361 | { | ||
362 | OSChatMessage c = new OSChatMessage(); | ||
363 | c.Message = msg; | ||
364 | c.Type = ChatTypeEnum.Say; | ||
365 | c.Channel = 0; | ||
366 | c.Position = PosOfGod; | ||
367 | c.From = _whoami; | ||
368 | c.Sender = null; | ||
369 | c.SenderUUID = UUID.Zero; | ||
370 | c.Scene = agent.Scene; | ||
371 | |||
372 | agent.ControllingClient.SendChatMessage(msg, (byte) ChatTypeEnum.Say, PosOfGod, _whoami, UUID.Zero, | ||
373 | (byte)ChatSourceType.Object, (byte)ChatAudibleLevel.Fully); | ||
374 | } | ||
323 | } | 375 | } |
324 | } \ No newline at end of file | 376 | } \ No newline at end of file |