Ejemplo n.º 1
0
        public virtual void Handle(GameClient session, ClientMessage message)
        {
            if (session?.GetHabbo()?.GetMessenger() != null)
            {
                string filteredMessage = TextUtilies.CheckBlacklistedWords(TextUtilies.FilterString(this.Message));

                List <string> receiverUsernames  = new List <string>();
                List <int>    receiverSessionIds = new List <int>();
                foreach (uint userId in this.SendTo)
                {
                    if (userId > 0) //real user
                    {
                        if (session.GetHabbo().GetMessenger().IsFriendWith(userId))
                        {
                            Skylight.GetGame().GetGameClientManager().GetGameClientById(userId)?.SendMessage(new MessengerReceivedRoomInviteComposerHandler(session.GetHabbo().ID, filteredMessage));
                        }
                        else
                        {
                            receiverUsernames.Add(Skylight.GetGame().GetGameClientManager().GetUsernameByID(userId));
                            receiverSessionIds.Add(-1);
                        }
                    }
                }

                Skylight.GetGame().GetChatlogManager().LogRoomInvite(session, this.SendTo.Where(u => u > 0).ToList(), receiverUsernames, receiverSessionIds, this.Message);
            }
        }
Ejemplo n.º 2
0
        public RoomData CreateRoom(GameClient gameClient, string roomName, string roomDescription, string roomModel, int categoryId, int maxUsers, int tradeType, RoomStateType state)
        {
            roomName = TextUtilies.CheckBlacklistedWords(TextUtilies.FilterString(roomName));
            if (this.RoomModels.ContainsKey(roomModel))
            {
                string clubName = this.RoomModels[roomModel].ClubName;
                if (string.IsNullOrEmpty(clubName) || gameClient.GetHabbo().GetSubscriptionManager().HasSubscription(clubName)) //hc check
                {
                    if (roomName.Length >= 1)
                    {
                        uint roomId = 0;
                        using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                        {
                            dbClient.AddParamWithValue("name", roomName);
                            dbClient.AddParamWithValue("description", roomDescription);
                            dbClient.AddParamWithValue("model", roomModel);
                            dbClient.AddParamWithValue("category", categoryId);
                            dbClient.AddParamWithValue("usersMax", maxUsers);
                            dbClient.AddParamWithValue("ownerid", gameClient.GetHabbo().ID);
                            dbClient.ExecuteQuery("INSERT INTO rooms(type, name, description, model, category, users_max, trade, ownerid, data, state) VALUES('private', @name, @description, @model, @category, @usersMax, '" + tradeType + "', @ownerid, '', '" + (state == RoomStateType.PASSWORD ? "password" : state == RoomStateType.LOCKED ? "locked" : "open") + "')");
                            roomId = (uint)dbClient.GetID();
                        }
                        gameClient.GetHabbo().AddRoom(roomId);

                        return(this.TryGetAndLoadRoomData(roomId));
                    }
                    else
                    {
                        gameClient.SendNotif("Room name is too short!");
                        return(null);
                    }
                }
                else
                {
                    gameClient.SendNotif("You need HC/VIP to use this room model!");
                    return(null);
                }
            }
            else
            {
                gameClient.SendNotif("This room model havent yet added! Please try again later!");
                return(null);
            }
        }
Ejemplo n.º 3
0
        public virtual void Handle(GameClient session, ClientMessage message)
        {
            Room room = session?.GetHabbo()?.GetRoomSession()?.GetRoom();

            if (room != null)
            {
                if (!room.RoomMute || session.GetHabbo().HasPermission("acc_ignore_roommute"))
                {
                    if (!session.GetHabbo().IsMuted())
                    {
                        session.GetHabbo().GetRoomSession().GetRoomUser().Unidle();

                        if (session.GetHabbo().GetRoomSession().GetRoomUser().CheckForFloor())
                        {
                            session.GetHabbo().GetRoomSession().GetRoomUser().FloodUser();
                        }
                        else
                        {
                            session.GetHabbo().LastRoomMessage = DateTime.Now;
                            session.GetHabbo().FloodCounter++;
                        }


                        RoomUnitUser user = room.RoomUserManager.GetUserByName(this.Username);
                        if (user != null)
                        {
                            string filteredMessage = TextUtilies.CheckBlacklistedWords(TextUtilies.FilterString(this.Message));

                            if (!session.GetHabbo().HasPermission("acc_nochatlog_whisper"))
                            {
                                Skylight.GetGame().GetChatlogManager().LogRoomMessage(session, "Whisper" + (char)9 + user.Session.GetHabbo().ID + (char)9 + this.Message);
                            }

                            session.GetHabbo().GetUserSettings().ChatColor = this.Bubble;

                            session.SendMessage(new ReceiveWhisperComposerHandler(session.GetHabbo().GetRoomSession().GetRoomUser().VirtualID, filteredMessage, this.Bubble));
                            user.Session.SendMessage(new ReceiveWhisperComposerHandler(session.GetHabbo().GetRoomSession().GetRoomUser().VirtualID, filteredMessage, this.Bubble));
                        }
                    }
                }
            }
        }
        public virtual void Handle(GameClient session, ClientMessage message)
        {
            if (session?.GetHabbo()?.GetMessenger() != null)
            {
                if (this.UserID > 0) //Real user
                {
                    if (!session.GetHabbo().GetMessenger().IsFriendWith(this.UserID))
                    {
                        session.SendMessage(new MessengerSendPrivateMessageErrorComposerHandler(this.UserID, MessengerSendPrivateMessageErrorCode.NotFriend));
                    }
                    else
                    {
                        if (session.GetHabbo().IsMuted())
                        {
                            session.SendMessage(new MessengerSendPrivateMessageErrorComposerHandler(this.UserID, MessengerSendPrivateMessageErrorCode.SenderMuted));
                        }
                        else
                        {
                            GameClient target = Skylight.GetGame().GetGameClientManager().GetGameClientById(this.UserID);
                            if (target?.GetHabbo()?.GetMessenger() != null)
                            {
                                if (target.GetHabbo().IsMuted())
                                {
                                    session.SendMessage(new MessengerSendPrivateMessageErrorComposerHandler(this.UserID, MessengerSendPrivateMessageErrorCode.ReceiverMuted));
                                }
                                else
                                {
                                    string filteredMessage = TextUtilies.CheckBlacklistedWords(TextUtilies.FilterString(this.Message));

                                    if (!session.GetHabbo().HasPermission("acc_nochatlog_pm"))
                                    {
                                        Skylight.GetGame().GetChatlogManager().LogPrivateMessage(session, target, this.Message);
                                    }

                                    target.SendMessage(new MessengerReceivePrivateMessageComposerHandler(session.GetHabbo().ID, filteredMessage));
                                }
                            }
                            else
                            {
                                session.SendMessage(new MessengerSendPrivateMessageErrorComposerHandler(this.UserID, MessengerSendPrivateMessageErrorCode.Offline));
                            }
                        }
                    }
                }
                else if (this.UserID == 0) //Staff chat
                {
                    if (session.GetHabbo().HasPermission("acc_staffchat"))
                    {
                        List <uint>   receiverIds        = new List <uint>();
                        List <string> receiverUsernames  = new List <string>();
                        List <int>    receiverSessionIds = new List <int>();

                        foreach (GameClient session_ in Skylight.GetGame().GetGameClientManager().GetClients())
                        {
                            if ((session_?.GetHabbo()?.HasPermission("acc_staffchat") ?? false) && session_.GetHabbo().ID != session.GetHabbo().ID)
                            {
                                receiverIds.Add(session_.GetHabbo().ID);
                                receiverUsernames.Add(session_.GetHabbo().Username);
                                receiverSessionIds.Add(session_.SessionID);

                                session_.SendMessage(new MessengerReceivePrivateMessageComposerHandler(this.UserID, this.Message, 0, session.GetHabbo().Username, session.GetHabbo().Look, session.GetHabbo().ID));
                            }
                        }

                        Skylight.GetGame().GetChatlogManager().LogStaffChatMessage(session, receiverIds, receiverUsernames, receiverSessionIds, this.Message);
                    }
                    else
                    {
                        session.SendMessage(new MessengerSendPrivateMessageErrorComposerHandler(this.UserID, MessengerSendPrivateMessageErrorCode.NotFriend));
                    }
                }
                else //Group chats
                {
                    //MUCH TODO

                    session.SendMessage(new MessengerSendPrivateMessageErrorComposerHandler(this.UserID, MessengerSendPrivateMessageErrorCode.Offline));
                }
            }
        }
        public void Handle(GameClient session, ClientMessage message)
        {
            if (session != null && session.GetHabbo() != null && session.GetHabbo().GetRoomSession() != null)
            {
                Room room = Skylight.GetGame().GetRoomManager().TryGetRoom(session.GetHabbo().GetRoomSession().CurrentRoomID);
                if (room != null && room.HaveOwnerRights(session))
                {
                    uint   roomId = message.PopWiredUInt();
                    string name   = TextUtilies.CheckBlacklistedWords(TextUtilies.FilterString(message.PopFixedString()));
                    if (name.Length > 100)
                    {
                        name = name.Substring(0, 100);
                    }

                    string description = TextUtilies.CheckBlacklistedWords(TextUtilies.FilterString(message.PopFixedString()));
                    if (description.Length > 255)
                    {
                        description = description.Substring(0, 255);
                    }

                    int state = message.PopWiredInt32();
                    if (state < 0 || state > 2)
                    {
                        state = (int)room.RoomData.State;
                    }

                    string password = TextUtilies.FilterString(message.PopFixedString());
                    if (password.Length > 30)
                    {
                        password = room.RoomData.Password;
                    }

                    int usersMax = message.PopWiredInt32();
                    if (usersMax < 0 || usersMax % 5 == 1 || usersMax > 100)
                    {
                        usersMax = room.RoomData.UsersMax;
                    }

                    int category = message.PopWiredInt32();
                    if (Skylight.GetGame().GetNavigatorManager().GetFlatCat(category) == null) //invalid category
                    {
                        category = room.RoomData.Category;
                    }

                    string tags      = "";
                    int    tagsCount = message.PopWiredInt32();
                    if (tagsCount >= 0 && tagsCount <= 2)
                    {
                        for (int i = 0; i < tagsCount; i++)
                        {
                            if (i > 0)
                            {
                                tags += ",";
                            }

                            tags += TextUtilies.CheckBlacklistedWords(TextUtilies.FilterString(message.PopFixedString()));
                        }

                        if (tags.Length > 100)
                        {
                            tags = string.Join(",", room.RoomData.Tags);
                        }
                    }
                    else
                    {
                        tags = string.Join(",", room.RoomData.Tags);
                    }

                    bool allowPets        = message.PopBase64Boolean();
                    bool allowPetsEat     = message.PopBase64Boolean();
                    bool allowWalkthrough = message.PopBase64Boolean();
                    bool hidewalls        = message.PopBase64Boolean();

                    int wallthick = message.PopWiredInt32();
                    if (wallthick < -2 || wallthick > 1)
                    {
                        wallthick = room.RoomData.Wallthick;
                    }

                    int floorthick = message.PopWiredInt32();
                    if (floorthick < -2 || floorthick > 1)
                    {
                        floorthick = room.RoomData.Floorthick;
                    }

                    room.RoomData.Name             = name;
                    room.RoomData.Description      = description;
                    room.RoomData.State            = (RoomStateType)state;
                    room.RoomData.Password         = password;
                    room.RoomData.UsersMax         = usersMax;
                    room.RoomData.Category         = category;
                    room.RoomData.Tags             = tags.Split(',').ToList();
                    room.RoomData.AllowPets        = allowPets;
                    room.RoomData.AllowPetsEat     = allowPetsEat;
                    room.RoomData.AllowWalkthrough = allowWalkthrough;
                    room.RoomData.Hidewalls        = hidewalls;
                    room.RoomData.Wallthick        = wallthick;
                    room.RoomData.Floorthick       = floorthick;

                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("roomid", room.ID);
                        dbClient.AddParamWithValue("name", name);
                        dbClient.AddParamWithValue("description", description);
                        dbClient.AddParamWithValue("state", room.RoomData.State == RoomStateType.PASSWORD ? "password" : room.RoomData.State == RoomStateType.LOCKED ? "locked" : "open");
                        dbClient.AddParamWithValue("password", password);
                        dbClient.AddParamWithValue("users_max", usersMax);
                        dbClient.AddParamWithValue("category", category);
                        dbClient.AddParamWithValue("tags", tags);
                        dbClient.AddParamWithValue("allow_pets", allowPets ? "1" : "0");
                        dbClient.AddParamWithValue("allow_pets_eat", allowPetsEat ? "1" : "0");
                        dbClient.AddParamWithValue("allow_walkthrough", allowWalkthrough ? "1" : "0");
                        dbClient.AddParamWithValue("hidewalls", hidewalls ? "1" : "0");
                        dbClient.AddParamWithValue("wallthick", wallthick);
                        dbClient.AddParamWithValue("floorthick", floorthick);

                        dbClient.ExecuteQuery("UPDATE rooms SET name = @name, description = @description, state = @state, password = @password, users_max = @users_max, category = @category, tags = @tags, allow_pets = @allow_pets, allow_pets_eat = @allow_pets_eat, allow_walkthrough = @allow_walkthrough, hidewalls = @hidewalls, wallthick = @wallthick, floorthick = @floorthick WHERE id = @roomid LIMIT 1");
                    }

                    room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.RoomSettingsOK, new ValueHolder("RoomID", room.ID)));
                    room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.RoomUpdateOK, new ValueHolder("RoomID", room.ID)));
                    room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.RoomVIPSettings, new ValueHolder("Hidewalls", room.RoomData.Hidewalls, "Wallthick", room.RoomData.Wallthick, "Floorthick", room.RoomData.Floorthick)));
                    room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.RoomData, new ValueHolder("Room", room.RoomData)));
                }
            }
        }
Ejemplo n.º 6
0
        public void Handle(GameClient session, ClientMessage message)
        {
            if (session != null && session.GetHabbo() != null && session.GetHabbo().GetMessenger() != null)
            {
                int         count = message.PopWiredInt32();
                List <uint> users = new List <uint>();
                for (int i = 0; i < count; i++)
                {
                    uint userId = message.PopWiredUInt();
                    if (userId > 0)
                    {
                        users.Add(userId);
                    }
                }

                if (users.Count <= 0)
                {
                    return;
                }

                string text            = TextUtilies.FilterString(message.PopFixedString(), false, false);
                string filteredMessage = TextUtilies.CheckBlacklistedWords(text);

                ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                Message.Init(r63aOutgoing.MessengerRoomInvite);
                Message.AppendUInt(session.GetHabbo().ID);
                Message.AppendString(filteredMessage);

                List <string> receiverUsernames  = new List <string>();
                List <int>    receiverSessionIds = new List <int>();
                foreach (uint userId in users)
                {
                    if (session.GetHabbo().GetMessenger().IsFriendWith(userId))
                    {
                        GameClient gameClient = Skylight.GetGame().GetGameClientManager().GetGameClientById(userId);
                        if (gameClient != null)
                        {
                            if (gameClient.GetHabbo() != null)
                            {
                                receiverUsernames.Add(gameClient.GetHabbo().Username);
                                if (gameClient.GetHabbo().GetMessenger() != null && gameClient.GetHabbo().GetMessenger().IsFriendWith(session.GetHabbo().ID))
                                {
                                    gameClient.SendMessage(Message);
                                }
                            }
                            else
                            {
                                receiverUsernames.Add(Skylight.GetGame().GetGameClientManager().GetUsernameByID(userId));
                            }

                            receiverSessionIds.Add(gameClient.SessionID);
                        }
                        else
                        {
                            receiverUsernames.Add(Skylight.GetGame().GetGameClientManager().GetUsernameByID(userId));
                            receiverSessionIds.Add(-1);
                        }
                    }
                    else
                    {
                        receiverUsernames.Add(Skylight.GetGame().GetGameClientManager().GetUsernameByID(userId));
                        receiverSessionIds.Add(-1);
                    }
                }

                Skylight.GetGame().GetChatlogManager().LogRoomInvite(session, users, receiverUsernames, receiverSessionIds, text);
            }
        }
Ejemplo n.º 7
0
        public override void Speak(string message, bool shout, int bubble = 0)
        {
            string originalMessage = message;

            if (!this.Room.RoomMute || this.Session.GetHabbo().HasPermission("acc_ignore_roommute"))
            {
                if (!this.Session.GetHabbo().IsMuted())
                {
                    this.Unidle();

                    if (!message.StartsWith(":") || !this.HandleCommand(message.Substring(1))) //not a command
                    {
                        if (!this.Room.RoomWiredManager.UserSpeak(this, message))
                        {
                            if (this.CheckForFloor()) //flooded
                            {
                                this.FloodUser();
                            }
                            else
                            {
                                this.Session.GetHabbo().LastRoomMessage = DateTime.Now;
                                this.Session.GetHabbo().FloodCounter++;

                                if (!this.Session.GetHabbo().HasPermission("acc_nochatlog_say"))
                                {
                                    Skylight.GetGame().GetChatlogManager().LogRoomMessage(this.Session, originalMessage); //log it first bcs there can be some troubles to send it to everyone
                                }

                                message = TextUtilies.CheckBlacklistedWords(message);
                                if (shout)
                                {
                                    this.Room.SendToAllRespectIgnores(new MultiRevisionServerMessage(OutgoingPacketsEnum.Shout, new ValueHolder("VirtualID", this.VirtualID, "Message", message, "Bubble", bubble)), this.Session.GetHabbo().ID);
                                }
                                else
                                {
                                    this.Room.SendToAllRespectIgnores(new MultiRevisionServerMessage(OutgoingPacketsEnum.Chat, new ValueHolder("VirtualID", this.VirtualID, "Message", message, "Bubble", bubble)), this.Session.GetHabbo().ID);
                                }

                                foreach (BotAI bot in this.Room.RoomUserManager.GetBots())
                                {
                                    bot.OnUserSpeak(this, message, shout);
                                }
                            }
                        }
                        else
                        {
                            ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                            message_.Init(r63aOutgoing.Whisper);
                            message_.AppendInt32(this.VirtualID);
                            message_.AppendString(message);
                            message_.AppendInt32(0); //gesture
                            message_.AppendInt32(0); //links count
                            this.Session.SendMessage(message_);
                        }
                    }
                }
                else
                {
                    this.Session.SendNotif("You are muted!");
                }
            }
        }
Ejemplo n.º 8
0
        public void Handle(GameClient session, ClientMessage message)
        {
            if (session != null && session.GetHabbo() != null && session.GetHabbo().GetRoomSession() != null)
            {
                uint roomId = message.PopWiredUInt();

                Room room = Skylight.GetGame().GetRoomManager().TryGetRoom(session.GetHabbo().GetRoomSession().CurrentRoomID);
                if (room != null && room.HaveOwnerRights(session) && room.ID == roomId)
                {
                    string name = TextUtilies.CheckBlacklistedWords(TextUtilies.FilterString(message.PopFixedString()));
                    if (name.Length > 100)
                    {
                        name = name.Substring(0, 100);
                    }

                    string description = TextUtilies.CheckBlacklistedWords(TextUtilies.FilterString(message.PopFixedString()));
                    if (description.Length > 255)
                    {
                        description = description.Substring(0, 255);
                    }

                    int state = message.PopWiredInt32();
                    if (state < 0 || state > 3)
                    {
                        state = (int)room.RoomData.State;
                    }

                    string password = TextUtilies.FilterString(message.PopFixedString());
                    if (password.Length > 30)
                    {
                        password = room.RoomData.Password;
                    }

                    int usersMax = message.PopWiredInt32();
                    if (usersMax < 0 || usersMax % 5 == 1 || usersMax > 100)
                    {
                        usersMax = room.RoomData.UsersMax;
                    }

                    int category = message.PopWiredInt32();
                    if (Skylight.GetGame().GetNavigatorManager().GetFlatCat(category) == null) //invalid category
                    {
                        category = room.RoomData.Category;                                     // 0 = no category
                    }

                    string tags      = "";
                    int    tagsCount = message.PopWiredInt32();
                    if (tagsCount >= 0 && tagsCount <= 2)
                    {
                        for (int i = 0; i < tagsCount; i++)
                        {
                            if (i > 0)
                            {
                                tags += ",";
                            }

                            tags += TextUtilies.CheckBlacklistedWords(TextUtilies.FilterString(message.PopFixedString()));
                        }

                        if (tags.Length > 100)
                        {
                            tags = string.Join(",", room.RoomData.Tags);
                        }
                    }
                    else
                    {
                        tags = string.Join(",", room.RoomData.Tags);
                    }

                    int allowTrade = message.PopWiredInt32();
                    if (allowTrade < 0 || allowTrade > 2)
                    {
                        allowTrade = (int)room.RoomData.AllowTrade;
                    }

                    bool allowPets        = message.PopWiredBoolean();
                    bool allowPetsEat     = message.PopWiredBoolean();
                    bool allowWalkthrough = message.PopWiredBoolean();
                    bool hidewalls        = message.PopWiredBoolean();

                    int wallthick = message.PopWiredInt32();
                    if (wallthick < -2 || wallthick > 1)
                    {
                        wallthick = room.RoomData.Wallthick;
                    }

                    int floorthick = message.PopWiredInt32();
                    if (floorthick < -2 || floorthick > 1)
                    {
                        floorthick = room.RoomData.Floorthick;
                    }

                    int muteOption = message.PopWiredInt32();
                    if (muteOption < 0 || muteOption > 1)
                    {
                        muteOption = (int)room.RoomData.MuteOption;
                    }

                    int kickOption = message.PopWiredInt32();
                    if (kickOption < 0 || kickOption > 2)
                    {
                        kickOption = (int)room.RoomData.KickOption;
                    }

                    int banOption = message.PopWiredInt32();
                    if (banOption < 0 || banOption > 1)
                    {
                        banOption = (int)room.RoomData.BanOption;
                    }

                    int chatMode = message.PopWiredInt32();
                    if (chatMode < 0 || chatMode > 1)
                    {
                        chatMode = (int)room.RoomData.ChatMode;
                    }

                    int chatWeight = message.PopWiredInt32();
                    if (chatWeight < 0 || chatWeight > 2)
                    {
                        chatWeight = (int)room.RoomData.ChatWeight;
                    }

                    int chatSpeed = message.PopWiredInt32();
                    if (chatSpeed < 0 || chatSpeed > 2)
                    {
                        chatSpeed = (int)room.RoomData.ChatSpeed;
                    }

                    int chatDistance = message.PopWiredInt32();
                    if (chatDistance < 0 || chatDistance > 99)
                    {
                        chatDistance = room.RoomData.ChatDistance;
                    }

                    int chatProtection = message.PopWiredInt32();
                    if (chatProtection < 0 || chatProtection > 2)
                    {
                        chatProtection = (int)room.RoomData.ChatProtection;
                    }

                    room.RoomData.Name             = name;
                    room.RoomData.Description      = description;
                    room.RoomData.State            = (RoomStateType)state;
                    room.RoomData.Password         = password;
                    room.RoomData.UsersMax         = usersMax;
                    room.RoomData.Category         = category;
                    room.RoomData.Tags             = tags.Split(',').ToList();
                    room.RoomData.AllowTrade       = (RoomAllowTradeType)allowTrade;
                    room.RoomData.AllowPets        = allowPets;
                    room.RoomData.AllowPetsEat     = allowPetsEat;
                    room.RoomData.AllowWalkthrough = allowWalkthrough;
                    room.RoomData.Hidewalls        = hidewalls;
                    room.RoomData.Wallthick        = wallthick;
                    room.RoomData.Floorthick       = floorthick;
                    room.RoomData.MuteOption       = (RoomWhoCanType)muteOption;
                    room.RoomData.KickOption       = (RoomWhoCanType)kickOption;
                    room.RoomData.BanOption        = (RoomWhoCanType)banOption;
                    room.RoomData.ChatMode         = (RoomChatModeType)chatMode;
                    room.RoomData.ChatWeight       = (RoomChatWeightType)chatWeight;
                    room.RoomData.ChatSpeed        = (RoomChatSpeedType)chatSpeed;
                    room.RoomData.ChatDistance     = chatDistance;
                    room.RoomData.ChatProtection   = (RoomChatProtectionType)chatProtection;

                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("roomid", room.ID);
                        dbClient.AddParamWithValue("name", name);
                        dbClient.AddParamWithValue("description", description);
                        dbClient.AddParamWithValue("state", room.RoomData.State == RoomStateType.PASSWORD ? "password" : room.RoomData.State == RoomStateType.LOCKED ? "locked" : "open");
                        dbClient.AddParamWithValue("password", password);
                        dbClient.AddParamWithValue("users_max", usersMax);
                        dbClient.AddParamWithValue("category", category);
                        dbClient.AddParamWithValue("tags", tags);
                        dbClient.AddParamWithValue("allow_pets", allowPets ? "1" : "0");
                        dbClient.AddParamWithValue("allow_pets_eat", allowPetsEat ? "1" : "0");
                        dbClient.AddParamWithValue("allow_walkthrough", allowWalkthrough ? "1" : "0");
                        dbClient.AddParamWithValue("hidewalls", hidewalls ? "1" : "0");
                        dbClient.AddParamWithValue("wallthick", wallthick);
                        dbClient.AddParamWithValue("floorthick", floorthick);

                        dbClient.ExecuteQuery("UPDATE rooms SET name = @name, description = @description, state = @state, password = @password, users_max = @users_max, category = @category, tags = @tags, allow_pets = @allow_pets, allow_pets_eat = @allow_pets_eat, allow_walkthrough = @allow_walkthrough, hidewalls = @hidewalls, wallthick = @wallthick, floorthick = @floorthick, trade = '" + allowTrade + "', mute_option = '" + muteOption + "', kick_option = '" + kickOption + "', ban_option = '" + banOption + "', chat_mode = '" + chatMode + "', chat_weight = '" + chatWeight + "', chat_speed = '" + chatSpeed + "', chat_protection = '" + chatProtection + "' WHERE id = @roomid LIMIT 1");
                    }

                    room.SendToAll(OutgoingPacketsEnum.RoomSettingsOK, new ValueHolder("RoomID", room.ID));
                    room.SendToAll(OutgoingPacketsEnum.RoomUpdateOK, new ValueHolder("RoomID", room.ID));
                    room.SendToAll(OutgoingPacketsEnum.RoomVIPSettings, new ValueHolder("Hidewalls", hidewalls, "Wallthick", wallthick, "Floorthick", floorthick));
                    room.SendToAll(OutgoingPacketsEnum.RoomChatSettings, new ValueHolder("ChatMod", chatMode, "ChatWeight", chatWeight, "ChatSpeed", chatSpeed, "ChatDistance", chatDistance, "ChatProtection", chatProtection));
                    room.SendToAll(OutgoingPacketsEnum.RoomData, new ValueHolder("Room", room.RoomData));
                }
            }
        }
Ejemplo n.º 9
0
        public void Handle(GameClient session, ClientMessage message)
        {
            Room room = session.GetHabbo().GetRoomSession().GetRoom();

            if (room != null)
            {
                if (!session.GetHabbo().GetRoomSession().GetRoom().RoomMute || session.GetHabbo().HasPermission("acc_ignore_roommute"))
                {
                    if (!session.GetHabbo().IsMuted())
                    {
                        session.GetHabbo().GetRoomSession().GetRoomUser().Unidle();

                        if (session.GetHabbo().GetRoomSession().GetRoomUser().CheckForFloor())
                        {
                            session.GetHabbo().GetRoomSession().GetRoomUser().FloodUser();
                        }
                        else
                        {
                            session.GetHabbo().LastRoomMessage = DateTime.Now;
                            session.GetHabbo().FloodCounter++;

                            string[] data     = message.PopFixedString().Split(new char[] { ' ' }, 2);
                            string   username = data[0];
                            string   message_ = data[1];
                            if (message_.Length > 300)
                            {
                                message_ = message_.Substring(0, 300);
                            }
                            message_ = TextUtilies.FilterString(message_);

                            RoomUnitUser user = room.RoomUserManager.GetUserByName(username);
                            if (user != null)
                            {
                                if (!session.GetHabbo().HasPermission("acc_nochatlog_whisper"))
                                {
                                    Skylight.GetGame().GetChatlogManager().LogRoomMessage(session, "Whisper" + (char)9 + user.Session.GetHabbo().ID + (char)9 + message_);
                                }

                                message_ = TextUtilies.CheckBlacklistedWords(message_);

                                ServerMessage message_2 = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                message_2.Init(r63aOutgoing.Whisper);
                                message_2.AppendInt32(session.GetHabbo().GetRoomSession().GetRoomUser().VirtualID);

                                Dictionary <int, string> links = new Dictionary <int, string>();
                                if (message_.Contains("http://") || message_.Contains("www.") || message_.Contains("https://"))
                                {
                                    string[] words = message_.Split(' ');
                                    message_ = "";

                                    foreach (string word in words)
                                    {
                                        if (TextUtilies.ValidURL(word))
                                        {
                                            int index = links.Count;
                                            links.Add(index, word);

                                            message_ += " {" + index + "}";
                                        }
                                        else
                                        {
                                            message_ += " " + word;
                                        }
                                    }
                                }
                                message_2.AppendString(message_);
                                message_2.AppendInt32(RoomUnit.GetGesture(message_.ToLower())); //gesture
                                message_2.AppendInt32(links.Count);                             //links count
                                foreach (KeyValuePair <int, string> link in links)
                                {
                                    message_2.AppendString("/redirect.php?url=" + link.Value);
                                    message_2.AppendString(link.Value);
                                    message_2.AppendBoolean(true); //trushed, can link be opened
                                }
                                user.Session.SendMessage(message_2);
                                session.SendMessage(message_2);
                            }
                        }
                    }
                }
            }
        }