private void AddUserToGroup(Client Client, SiteRequest Request)
        {
            int ItemId = Request.PopInt32();

            if (ItemId <= 0)
            {
                return;
            }

            int FriendId = Request.PopInt32();

            if (FriendId <= 0)
            {
                return;
            }

            int CategoryId = Request.PopInt32();

            if (CategoryId <= 0)
            {
                return;
            }

            BrickEngine.GetMessengerHandler().AddUserToGroup(ItemId, Request.GetUserId(), FriendId, CategoryId);
        }
        private void AddUserTag(Client Client, SiteRequest Request)
        {
            string Tag = Request.PopString();

            if (!Client.GetUser().Tags.Contains(Tag))
            {
                Client.GetUser().Tags.Add(Tag);
            }
        }
        private void AddFriend(Client Client, SiteRequest Request)
        {
            int FriendId = Request.PopInt32();

            if (FriendId <= 0 || FriendId == Request.GetUserId())
            {
                return;
            }

            BrickEngine.GetMessengerHandler().RequestUser(Request.GetUserId(), FriendId);
        }
        public void HandlePacket(string Packet)
        {
            if (!string.IsNullOrEmpty(Packet))
            {
                if (Packet.Contains('_'))
                {
                    SiteRequest Request = new SiteRequest(BrickEngine.CleanString(Packet));

                    SiteRequestHandler.HandleRequest(Request);
                }
            }
        }
        public void HandleRequest(SiteRequest Request)
        {
            if (!Interactions.ContainsKey(Request.GetHeader()))
            {
                return;
            }

            if (NeedsOnline(Request.GetHeader()))
            {
                if (GainUserClient(Request) == null)
                {
                    return;
                }
            }

            Interactions[Request.GetHeader()].Invoke(GainUserClient(Request), Request);
        }
        private void UpdateEnableFollow(Client Client, SiteRequest Request)
        {
            Boolean EnableFollow = Request.PopBoolean();

            if (Client.GetUser().EnableFollow.Equals(EnableFollow))
            {
                return;
            }

            Client.GetUser().EnableFollow = EnableFollow;

            lock (Client.GetUser().MessengerLocker)
            {
                BrickEngine.GetMessengerHandler().AlertStatusFriends(Client.GetUser(), true);
            }
        }
        private void DeleteUserGroup(Client Client, SiteRequest Request)
        {
            int GroupId = Request.PopInt32();

            if (GroupId <= 0)
            {
                return;
            }

            BrickEngine.GetMessengerHandler().DeleteGroup(GroupId, Request.GetUserId());
        }
        private void EditUserGroup(Client Client, SiteRequest Request)
        {
            int GroupId = Request.PopInt32();

            if (GroupId <= 0)
            {
                return;
            }

            string Name = BrickEngine.CleanString(Request.PopString());

            if (string.IsNullOrEmpty(Name))
            {
                return;
            }

            if (!Regex.IsMatch(Name, @"^[a-zA-Z]+$"))
            {
                return;
            }

            if (Name.Length > 32)
            {
                Name = Name.Substring(32);
            }

            BrickEngine.GetMessengerHandler().RenameGroup(GroupId, Request.GetUserId(), Name);
        }
        private void UpdateMotto(Client Client, SiteRequest Request)
        {
            string Motto = BrickEngine.CleanString(Request.PopStringToEnd());

            if (Client.GetUser().Motto.Equals(Motto))
            {
                return;
            }

            Client.GetUser().Motto = Motto;
            Client.GetUser().RefreshUser();

            BrickEngine.GetStreamHandler().AddStream(Request.GetUserId(), HabboHotel.Users.Handlers.Messenger.Streaming.StreamType.EditedMotto, Motto);
        }
        private void UpdateEnableWordFilter(Client Client, SiteRequest Request)
        {
            Boolean EnableWordFilter = Request.PopBoolean();

            if (Client.GetUser().EnableWordfilter.Equals(EnableWordFilter))
            {
                return;
            }

            Client.GetUser().EnableWordfilter = EnableWordFilter;
        }
        private void UpdateEnableShowOnline(Client Client, SiteRequest Request)
        {
            Boolean EnableShowOnline = Request.PopBoolean();

            if (Client.GetUser().EnableShowOnline.Equals(EnableShowOnline))
            {
                return;
            }

            if (EnableShowOnline)
            {
                lock (Client.GetUser().MessengerLocker)
                {
                    BrickEngine.GetMessengerHandler().AlertStatusFriends(Client.GetUser(), true);
                }
            }
            else
            {
                lock (Client.GetUser().MessengerLocker)
                {
                    BrickEngine.GetMessengerHandler().AlertStatusFriends(Client.GetUser(), false);
                }
            }

            Client.GetUser().EnableShowOnline = EnableShowOnline;
        }
        private void UpdateEnableTrade(Client Client, SiteRequest Request)
        {
            Boolean EnableTrade = Request.PopBoolean();

            if (Client.GetUser().EnableTrade.Equals(EnableTrade))
            {
                return;
            }

            Client.GetUser().EnableTrade = EnableTrade;
        }
        private void DeleteFriend(Client Client, SiteRequest Request)
        {
            int FriendId = Request.PopInt32();

            if (FriendId <= 0 || FriendId == Request.GetUserId())
            {
                return;
            }

            if (!BrickEngine.GetMessengerHandler().HasFriend(Request.GetUserId(), FriendId))
            {
                return;
            }

            BrickEmulator.HabboHotel.Users.Handlers.Messenger.Friend Friend = BrickEngine.GetMessengerHandler().GetFriend(Request.GetUserId(), FriendId);

            if (Friend == null)
            {
                return;
            }

            if (Friend.IsAlive)
            {
                Response Response = new Response(13);
                Response.AppendBoolean(false);
                Response.AppendBoolean(true);
                Response.AppendInt32(-1);
                Response.AppendInt32(Request.GetUserId());

                Friend.GetClient().SendResponse(Response);
            }

            if (Client != null)
            {
                Response MyResponse = new Response(13);
                MyResponse.AppendBoolean(false);
                MyResponse.AppendBoolean(true);
                MyResponse.AppendInt32(-1);
                MyResponse.AppendInt32(FriendId);
                Client.SendResponse(MyResponse);
            }

            BrickEngine.GetMessengerHandler().DeleteFriend(Request.GetUserId(), FriendId);
        }
        private void UpdateEnableFriends(Client Client, SiteRequest Request)
        {
            Boolean EnableFriends = Request.PopBoolean();

            if (Client.GetUser().EnableNewFriends.Equals(EnableFriends))
            {
                return;
            }

            Client.GetUser().EnableNewFriends = EnableFriends;
        }
        private void UpdateCredits(Client Client, SiteRequest Request)
        {
            int Credits = Request.PopInt32();

            if (Credits <= 0)
            {
                Credits = 0;
            }

            if (Client.GetUser().Credits.Equals(Credits))
            {
                return;
            }

            Client.GetUser().Credits = Credits;
            Client.GetUser().UpdateCredits(false);
        }
 private void SignoutUser(Client Client, SiteRequest Request)
 {
     Client.Dispose();
 }
        private void RemoveUserTag(Client Client, SiteRequest Request)
        {
            string Tag = Request.PopString();

            if (Client.GetUser().Tags.Contains(Tag))
            {
                Client.GetUser().Tags.Remove(Tag);
            }
        }
        private void RemoveUserFromGroup(Client Client, SiteRequest Request)
        {
            int ItemId = Request.PopInt32();

            if (ItemId <= 0)
            {
                return;
            }

            BrickEngine.GetMessengerHandler().RemoveUserFromGroup(ItemId, Request.GetUserId());
        }
        private Client GainUserClient(SiteRequest Request)
        {
            if (!BrickEngine.GetUserReactor().IsOnline(Request.GetUserId()))
            {
                return null;
            }

            SocketClient Client = BrickEngine.GetSocketShield().GetSocketClientByHabboId(Request.GetUserId());

            if (Client == null || !Client.GetClient().IsValidUser)
            {
                return null;
            }

            return Client.GetClient();
        }