Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speech filter #1082

Merged
merged 8 commits into from
Jan 28, 2025
Merged

Speech filter #1082

merged 8 commits into from
Jan 28, 2025

Conversation

MiraHell
Copy link

@MiraHell MiraHell commented Jan 27, 2025

Что этот PR делает

Добавляет фильтр речи. Портирует ss220club/Paradise-SS220#1225

Closes #1078

Почему это хорошо для игры

Меньше нарушения атмосферы, меньше банов за слово на букву П

Тестирование

Локальные тесты

Changelog

🆑
add: Добавлен фильтр речи
server: Добавлено включение фильтра и список сикеев, которые его обходят в конфиге. Добавлен .json с фильтрами
/:cl:

Summary by Sourcery

Add a speech filter that censors specific words and phrases. The filter is configurable and can be bypassed by specific users.

New Features:

  • Implemented a configurable speech filter that replaces specific words and phrases with "цветочек".

Tests:

  • Tested locally.

Copy link

sourcery-ai bot commented Jan 27, 2025

Reviewer's Guide by Sourcery

This pull request implements a speech filter that replaces certain words with "цветочек". It also adds a configuration option to enable/disable the filter and a list of ckeys that can bypass the filter.

Sequence diagram for speech filtering process

sequenceDiagram
    participant User as User
    participant Mob as Mob
    participant Filter as SpeechFilter
    participant Config as Config

    User->>Mob: Say message
    activate Mob
    Mob->>Filter: filter_speech()
    activate Filter
    Filter->>Config: Check if filter enabled
    Config-->>Filter: Filter status
    alt filter enabled
        Filter->>Filter: Check bypass list
        alt user not in bypass list
            Filter->>Filter: Apply regex filter
            Filter-->>Mob: Return filtered message
            Filter->>User: Show warning message
            Filter->>Admin: Log filtered message
        else user in bypass list
            Filter-->>Mob: Return original message
        end
    else filter disabled
        Filter-->>Mob: Return original message
    end
    deactivate Filter
    Mob-->>User: Display message
    deactivate Mob
Loading

Class diagram for speech filter implementation

classDiagram
    class SpeechFilter {
        <<element>>
        -brainrot_notifications: list
        +Attach(target)
        +Detach(source, force)
        -filter_speech(talker, speech_args)
        -get_brainrot_filter_regex()
        -can_bypass_filter(mob_to_check)
    }

    class ConfigEntry {
        <<class>>
        +enable_speech_filter: flag
        +speech_filter_bypass: str_list
    }

    class Mob {
        +Login()
    }

    Mob ..> SpeechFilter : uses
    SpeechFilter ..> ConfigEntry : reads
Loading

File-Level Changes

Change Details Files
Added a speech filter element that censors specific words in player messages.
  • Created a new datum element /datum/element/speech_filter.
  • Implemented Attach and Detach procs to manage the filter's lifecycle.
  • Implemented filter_speech proc to intercept and modify player messages.
  • Implemented get_brainrot_filter_regex proc to load the filter regex from a JSON file.
  • Implemented can_bypass_filter proc to check if a player can bypass the filter.
modular_bandastation/speech_filter/code/speech_filter.dm
Added a configuration file for the speech filter.
  • Created a new JSON file brainrot_filter.json to store the filter regex.
config/bandastation/brainrot_filter.json
Added configuration entries for enabling/disabling the filter and for specifying bypass ckeys.
  • Added a new config entry /datum/config_entry/flag/enable_speech_filter.
  • Added a new config entry /datum/config_entry/str_list/speech_filter_bypass.
modular_bandastation/speech_filter/code/configuration.dm
Added a speech filter modpack.
  • Created a new modpack /datum/modpack/speech_filter.
  • Added a new dme file for the modpack.
modular_bandastation/speech_filter/_speech_filter.dm
modular_bandastation/speech_filter/_speech_filter.dme
Attached the speech filter to the mob on login.
  • Modified the /mob/living/Login proc to add the speech filter element.
modular_bandastation/speech_filter/code/mob.dm
Modified the main configuration file to include the new filter options.
  • Added new configuration options for the speech filter.
config/bandastation/bandastation_config.txt

Assessment against linked issues

Issue Objective Addressed Explanation
#1078 Implement a speech filter for the game
#1078 Reduce atmosphere violations and potential bans

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions bot added the 💾 Изменение конфига Ф-ф-фуриор...? label Jan 27, 2025
@ss220app ss220app bot added the 📜 CL валиден Этот чейнджлог будет успешно опубликован label Jan 27, 2025
Copy link
Collaborator

@dj-34 dj-34 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне больше нечего добавить

modular_bandastation/speech_filter/_speech_filter.dm Outdated Show resolved Hide resolved
@Gaxeer Gaxeer merged commit e21fd0c into ss220club:master Jan 28, 2025
24 checks passed
ss220app bot added a commit that referenced this pull request Jan 28, 2025
## If enabled, some words will be removed from player's messages.
# ENABLE_SPEECH_FILTER
## List of ckeys, that bypass speech filter.
# SPEECH_FILTER_BYPASS ckey
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У нас на паре так реализовано? Почему не отдельный файл...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

На паре основной конфиг в .toml

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно было добавить еще один ключ в brainrot_filter.json, но не думаю, что много кому надо обходить фильтр, максимум самим стримерам

@MiraHell MiraHell deleted the speech-filter branch January 28, 2025 12:18
@Graybear98
Copy link

Получаешь ли ты ещё дебаф к настроению?

@MiraHell
Copy link
Author

Получаешь ли ты ещё дебаф к настроению?

Нет

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💾 Изменение конфига Ф-ф-фуриор...? 📜 CL валиден Этот чейнджлог будет успешно опубликован
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Прикрутить брейнрот фильтр с Пары
5 participants