Пример #1
0
 public static string TrimAndFilterProfanity(string text)
 {
     text = text?.Trim() ?? string.Empty;
     text = TrimSpacesOnEachLine(text);
     text = ProfanityFilteringSystem.SharedApplyFilters(text);
     return(text);
 }
Пример #2
0
        public string ClientGetFilteredMessage()
        {
            var message = this.Message;

            var isFromCurrentPlayer = Api.Client.Characters.CurrentPlayerCharacter.Name?.Equals(this.From)
                                      ?? false;

            if (isFromCurrentPlayer)
            {
                // don't apply filtering to the current player's messages
                return(message);
            }

            if (Api.Client.SteamApi.IsSteamClient)
            {
                // Apply user-configurable Steam text filters
                // (in some countries there is mandatory filtering).
                // https://store.steampowered.com/news/app/593110/view/2855803154584367415
                message = Api.Client.SteamApi.FilterText(message);
            }

            // Apply our profanity filters (extendable with mods).
            message = ProfanityFilteringSystem.SharedApplyFilters(message);

            return(message);
        }
Пример #3
0
        public static bool ContainsProfanityOrProhibited(string clanTag)
        {
            if (string.IsNullOrEmpty(clanTag))
            {
                return(true);
            }

            clanTag = ProfanityFilteringSystem.SharedApplyFilters(clanTag);
            if (clanTag.IndexOf(ProfanityFilteringSystem.ProfanityFilterReplacementChar)
                >= 0)
            {
                // found profanity
                return(true);
            }

            foreach (var entry in BlockList)
            {
                if (entry[entry.Length - 1] == '*')
                {
                    if (clanTag.StartsWith(entry.Substring(0, entry.Length - 1), StringComparison.OrdinalIgnoreCase))
                    {
                        // matched a block list entry with wildcard
                        return(true);
                    }
                }
                else if (clanTag.Equals(entry))
                {
                    // matched a block list entry
                    return(true);
                }
            }

            return(false);
        }
Пример #4
0
 public static void ClientOfficerSetFactionDescription(string text, bool isPrivateDescription)
 {
     ClientValidateHasAccessRights(FactionMemberAccessRights.EditDescription);
     text = ProfanityFilteringSystem.SharedApplyFilters(text);
     SharedValidateDescriptionLength(text, isPrivateDescription);
     Instance.CallServer(
         _ => _.ServerRemote_OfficerSetDescription(text, isPrivateDescription));
 }
Пример #5
0
        private void ServerRemote_SetSignText(IStaticWorldObject worldObjectSign, string signText)
        {
            this.VerifyGameObject(worldObjectSign);

            if (!this.SharedCanInteract(ServerRemoteContext.Character, worldObjectSign, writeToLog: true))
            {
                return;
            }

            signText = signText?.Trim();
            SharedValidateSignText(signText);
            signText = ProfanityFilteringSystem.SharedApplyFilters(signText);
            GetPublicState(worldObjectSign).Text = signText;
        }
Пример #6
0
        public void ClientSetSignText(IStaticWorldObject worldObjectSign, string text)
        {
            text = text?.Trim();
            SharedValidateSignText(text);

            if (Client.SteamApi.IsSteamClient)
            {
                text = Client.SteamApi.FilterText(text);
            }

            text = ProfanityFilteringSystem.SharedApplyFilters(text);

            this.CallServer(_ => _.ServerRemote_SetSignText(worldObjectSign, text));
        }
Пример #7
0
        private bool ServerRemote_SetDescription(string text)
        {
            text = text?.Trim() ?? string.Empty;
            text = SharedTextHelper.TrimSpacesOnEachLine(text);

            if (text.Length > MaxDescriptionLength)
            {
                throw new Exception("Max description length exceeded");
            }

            text = ProfanityFilteringSystem.SharedApplyFilters(text);
            Api.Server.Core.DescriptionMessageText = serverDescriptionText = text;

            Logger.Important("Server description message changed to:"
                             + Environment.NewLine
                             + text.Replace("[br]", Environment.NewLine + "[br]"));
            return(true);
        }
Пример #8
0
        public static async void ClientEditDescription()
        {
            var originalText = await Instance.CallServer(_ => _.ServerRemote_GetDescriptionMessage());

            BbTextEditorHelper.ClientOpenTextEditor(originalText,
                                                    maxLength: MaxDescriptionLength,
                                                    windowHeight: 200,
                                                    onSave: OnSave);

            async void OnSave(string text)
            {
                if (Api.Client.SteamApi.IsSteamClient)
                {
                    text = Api.Client.SteamApi.FilterText(text);
                }

                text = ProfanityFilteringSystem.SharedApplyFilters(text);

                await Instance.CallServer(_ => _.ServerRemote_SetDescription(text));

                RefreshDescription();
            }
        }
Пример #9
0
        public static async void ClientEditWelcomeMessage()
        {
            var welcomeMessageData = await Instance.CallServer(_ => _.ServerRemote_GetInfo());

            BbTextEditorHelper.ClientOpenTextEditor(welcomeMessageData.WelcomeMessage,
                                                    maxLength: MaxWelcomeMessageLength,
                                                    windowHeight: 530,
                                                    onSave: OnSave);

            async void OnSave(string text)
            {
                if (Api.Client.SteamApi.IsSteamClient)
                {
                    text = Api.Client.SteamApi.FilterText(text);
                }

                text = ProfanityFilteringSystem.SharedApplyFilters(text);

                await Instance.CallServer(_ => _.ServerRemote_SetWelcomeMessage(text));

                RefreshWelcomeMessage();
            }
        }
Пример #10
0
        private void ServerRemote_OfficerSetDescription(string text, bool isPrivateDescription)
        {
            text = text?.Trim() ?? string.Empty;
            text = SharedTextHelper.TrimSpacesOnEachLine(text);

            var officer = ServerRemoteContext.Character;

            ServerValidateHasAccessRights(officer,
                                          FactionMemberAccessRights.EditDescription,
                                          out var faction);

            text = ProfanityFilteringSystem.SharedApplyFilters(text);
            SharedValidateDescriptionLength(text, isPrivateDescription);

            var privateState = Faction.GetPrivateState(faction);

            if (isPrivateDescription)
            {
                if (privateState.DescriptionPrivate == text)
                {
                    return;
                }

                privateState.DescriptionPrivate = text;
            }
            else
            {
                if (privateState.DescriptionPublic == text)
                {
                    return;
                }

                privateState.DescriptionPublic = text;
            }

            ServerAddLogEntry(faction, new FactionLogEntryDescriptionChanged(officer));
        }