예제 #1
0
        private static void UserChat(Session Session, ClientMessage Message)
        {
            if (Session.CharacterInfo.IsMuted)
            {
                return;
            }

            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null)
            {
                return;
            }

            RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId);

            if (Actor == null)
            {
                return;
            }

            bool   Shout       = (Message.Id == OpcodesIn.ROOM_CHAT_SHOUT);
            string MessageText = UserInputFilter.FilterString(Message.PopString());

            if (MessageText.Length == 0)
            {
                return;
            }

            if (MessageText.Length > 100)
            {
                MessageText = MessageText.Substring(0, 100);
            }

            MessageText = Wordfilter.Filter(MessageText);

            if (MessageText.StartsWith(":") && (ChatCommands.HandleCommand(Session, MessageText) ||
                                                Session.HasRight("moderation_tool")))
            {
                return;
            }

            if (Instance.WiredManager.HandleChat(MessageText, Actor))
            {
                Actor.Whisper(MessageText, 0);
                return;
            }

            Actor.Chat(MessageText, Shout, Session.HasRight("mute"));

            if (Instance.HumanActorCount > 1)
            {
                QuestManager.ProgressUserQuest(Session, QuestType.SOCIAL_CHAT);
            }
        }
예제 #2
0
        private static void OnInvite(Session Session, ClientMessage Message)
        {
            int         Count   = Message.PopWiredInt32();
            List <uint> Targets = new List <uint>();

            for (int i = 0; (i < Count && i < 50); i++)
            {
                Targets.Add(Message.PopWiredUInt32());
            }

            string MessageText = UserInputFilter.FilterString(Message.PopString());

            if (MessageText.Length > 121)
            {
                MessageText = MessageText.Substring(0, 121);
            }

            List <Session> Users = new List <Session>();

            foreach (uint UserId in Targets)
            {
                if (!Session.MessengerFriendCache.Friends.Contains(UserId))
                {
                    continue;
                }

                Session TargetSession = SessionManager.GetSessionByCharacterId(UserId);

                if (TargetSession == null)
                {
                    continue;
                }

                Users.Add(TargetSession);

                TargetSession.SendData(MessengerImInviteComposer.Compose(Session.CharacterId, Wordfilter.Filter(MessageText)));
            }

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                String to = "";
                foreach (Session User in Users)
                {
                    to += User.CharacterInfo.Username + " [" + User.CharacterId + "], ";
                }
                to = to.Substring(0, to.Length - 2);
                ModerationLogs.LogChatMessage(MySqlClient, Session.CharacterId, 0, "(INVITATION to " + to + ") " + MessageText);
            }
        }
예제 #3
0
        private static void OnSendIm(Session Session, ClientMessage Message)
        {
            uint   UserId = Message.PopWiredUInt32();
            string Text   = UserInputFilter.FilterString(Message.PopString()).Trim();

            if (UserId <= 0 || Text.Length < 1)
            {
                return;
            }

            if (Session.CharacterInfo.IsMuted)
            {
                Session.SendData(MessengerImErrorComposer.Compose(4, UserId));
                return;
            }

            if (!Session.MessengerFriendCache.Friends.Contains(UserId))
            {
                Session.SendData(MessengerImErrorComposer.Compose(6, UserId));
                return;
            }

            Session TargetSession = SessionManager.GetSessionByCharacterId(UserId);

            if (TargetSession == null)
            {
                Session.SendData(MessengerImErrorComposer.Compose(5, UserId));
                return;
            }

            if (TargetSession.CharacterInfo.IsMuted)
            {
                Session.SendData(MessengerImErrorComposer.Compose(3, UserId));
            }

            TargetSession.SendData(MessengerImMessageComposer.Compose(Session.CharacterId, Wordfilter.Filter(Text)));

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                ModerationLogs.LogChatMessage(MySqlClient, Session.CharacterId, 0, "(MESSAGE to " + TargetSession.CharacterInfo.Username + " [" + TargetSession.CharacterId + "]) " + Text);
            }
        }