Exemple #1
0
        private void chatting(Object sender, IrcMessageEventArgs <TextMessage> e, IScenePresence presence)
        {
            IChatModule chatModule = m_scene.RequestModuleInterface <IChatModule>();

            if (chatModule != null)
            {
                if (e.Message.Targets.Count > 0 && e.Message.Targets[0] == clients[presence.UUID].User.Nick)
                {
                    UUID fakeUUID;
                    if (!m_ircUsersToFakeUUIDs.TryGetValue(e.Message.Sender.UserName, out fakeUUID))
                    {
                        fakeUUID = UUID.Random();
                        m_ircUsersToFakeUUIDs[e.Message.Sender.UserName] = fakeUUID;
                    }
                    presence.ControllingClient.SendInstantMessage(new GridInstantMessage()
                    {
                        FromAgentID   = fakeUUID,
                        FromAgentName = e.Message.Sender.Nick,
                        ToAgentID     = presence.UUID,
                        Dialog        = (byte)InstantMessageDialog.MessageFromAgent,
                        Message       = e.Message.Text,
                        FromGroup     = false,
                        SessionID     = UUID.Zero,
                        Offline       = 0,
                        BinaryBucket  = new byte[0],
                        Timestamp     = (uint)Util.UnixTimeSinceEpoch()
                    });
                }
                else
                {
                    chatModule.TrySendChatMessage(presence, presence.AbsolutePosition, UUID.Zero,
                                                  e.Message.Targets[0] + " - " + e.Message.Sender.Nick, ChatTypeEnum.Say, e.Message.Text, ChatSourceType.Agent, 20);
                }
            }
        }
Exemple #2
0
        public void llRegionSayTo(LSL_Key toID, int channelID, string text)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return;
            }

            IChatModule chatModule = World.RequestModuleInterface <IChatModule>();

            if (text.Length > 1023)
            {
                text = text.Substring(0, 1023);
            }
            if (channelID == 0)
            {
                IScenePresence presence = World.GetScenePresence(UUID.Parse(toID.m_string));
                if (presence != null)
                {
                    if (chatModule != null)
                    {
                        chatModule.TrySendChatMessage(presence, m_host.AbsolutePosition,
                                                      m_host.UUID, m_host.Name, ChatTypeEnum.Say, text,
                                                      ChatSourceType.Object, 10000);
                    }
                }
            }

            if (m_comms != null)
            {
                m_comms.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID,
                                       UUID.Parse(toID.m_string), text);
            }
        }
Exemple #3
0
        private static void JoinChannel(Client client, string channel, IScenePresence presence)
        {
            client.SendJoin(channel);
            IChatModule chatModule = presence.Scene.RequestModuleInterface <IChatModule>();

            if (chatModule != null)
            {
                chatModule.TrySendChatMessage(presence, presence.AbsolutePosition, UUID.Zero,
                                              "System", ChatTypeEnum.Say, "You joined " + channel, ChatSourceType.Agent, 20);
            }
        }
        public bool OnNewChatMessageFromWorld(OSChatMessage c, out OSChatMessage newc)
        {
            bool           isGod = false;
            IScenePresence sP    = c.Scene.GetScenePresence(c.SenderUUID);

            if (sP != null)
            {
                if (!sP.IsChildAgent)
                {
                    // Check if the sender is a 'god...'
                    if (sP.GodLevel != 0)
                    {
                        isGod = true;

                        // add to authorized users
                        if (!m_authorizedSpeakers.Contains(c.SenderUUID))
                        {
                            m_authorizedSpeakers.Add(c.SenderUUID);
                        }

                        if (!m_authList.Contains(c.SenderUUID))
                        {
                            m_authList.Add(c.SenderUUID);
                        }
                    }

                    //Check that the agent is allowed to speak in this region
                    if (!m_authorizedSpeakers.Contains(c.SenderUUID))
                    {
                        //They can't talk, so block it
                        newc = c;
                        return(false);
                    }
                }
            }

            if (c.Message.Contains("Chat."))
            {
                if (!m_useAuth || m_authList.Contains(c.SenderUUID))
                {
                    IScenePresence senderSP;
                    c.Scene.TryGetScenePresence(c.SenderUUID, out senderSP);
                    string [] message = c.Message.Split('.');
                    if (message [1] == "SayDistance")
                    {
                        chatModule.SayDistance = Convert.ToInt32(message [2]);
                        chatModule.TrySendChatMessage(senderSP, c.Position,
                                                      UUID.Zero, "UniverseChat", ChatTypeEnum.Region,
                                                      message [1] + " changed.", ChatSourceType.System, -1);
                    }
                    if (message [1] == "WhisperDistance")
                    {
                        chatModule.WhisperDistance = Convert.ToInt32(message [2]);
                        chatModule.TrySendChatMessage(senderSP, c.Position,
                                                      UUID.Zero, "UniverseChat", ChatTypeEnum.Region,
                                                      message [1] + " changed.", ChatSourceType.System, -1);
                    }
                    if (message [1] == "ShoutDistance")
                    {
                        chatModule.ShoutDistance = Convert.ToInt32(message [2]);
                        chatModule.TrySendChatMessage(senderSP, c.Position,
                                                      UUID.Zero, "UniverseChat", ChatTypeEnum.Region,
                                                      message [1] + " changed.", ChatSourceType.System, -1);
                    }
                    //Add the user to the list of allowed speakers and 'chat' admins
                    if (message [1] == "AddToAuth")
                    {
                        IScenePresence NewSP;
                        c.Scene.TryGetAvatarByName(message [2], out NewSP);
                        m_authList.Add(NewSP.UUID);
                        chatModule.TrySendChatMessage(senderSP, c.Position,
                                                      UUID.Zero, "UniverseChat", ChatTypeEnum.Region,
                                                      message [2] + " added.", ChatSourceType.System, -1);
                    }
                    if (message [1] == "RemoveFromAuth")
                    {
                        IScenePresence NewSP;
                        c.Scene.TryGetAvatarByName(message [2], out NewSP);
                        m_authList.Remove(NewSP.UUID);
                        chatModule.TrySendChatMessage(senderSP, c.Position,
                                                      UUID.Zero, "UniverseChat", ChatTypeEnum.Region,
                                                      message [2] + " added.", ChatSourceType.System, -1);
                    }
                    //Block chat from those not in the auth list
                    if (message [1] == "BlockChat")
                    {
                        m_blockChat = true;
                        chatModule.TrySendChatMessage(senderSP, c.Position,
                                                      UUID.Zero, "UniverseChat", ChatTypeEnum.Region, "Chat blocked.",
                                                      ChatSourceType.System, -1);
                    }
                    //Allow chat from all again
                    if (message [1] == "AllowChat")
                    {
                        m_blockChat = false;
                        chatModule.TrySendChatMessage(senderSP, c.Position,
                                                      UUID.Zero, "UniverseChat", ChatTypeEnum.Region, "Chat allowed.",
                                                      ChatSourceType.System, -1);
                    }
                    //Remove speaking privileges from an individual
                    if (message [1] == "RevokeSpeakingRights")
                    {
                        IScenePresence NewSP;
                        c.Scene.TryGetAvatarByName(message [2], out NewSP);
                        m_authorizedSpeakers.Remove(NewSP.UUID);
                        chatModule.TrySendChatMessage(senderSP, c.Position,
                                                      UUID.Zero, "UniverseChat", ChatTypeEnum.Region,
                                                      message [2] + " - revoked.", ChatSourceType.System, -1);
                    }
                    //Allow an individual to speak again
                    if (message [1] == "GiveSpeakingRights")
                    {
                        IScenePresence NewSP;
                        c.Scene.TryGetAvatarByName(message [2], out NewSP);
                        m_authorizedSpeakers.Add(NewSP.UUID);
                        chatModule.TrySendChatMessage(senderSP, c.Position,
                                                      UUID.Zero, "UniverseChat", ChatTypeEnum.Region,
                                                      message [2] + " - revoked.", ChatSourceType.System, -1);
                    }
                }

                newc = c;
                // Block commands from normal chat
                return(false);
            }

            if (sP != null)
            {
                //Add the god prefix
                if (isGod && m_indicategod)
                {
                    c.Message = m_godPrefix + c.Message;
                }
            }

            newc = c;
            return(true);
        }