forked from ParadiseSS13/Paradise
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Brainrot filter #1225
Merged
Merged
Brainrot filter #1225
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b92dff7
feat: add brainrot filter
Gaxeer 6aee5e4
tweak: reset config back
Gaxeer 9c5e461
tweak: remove trailing new line from `modular_ss220.dme`
Gaxeer eb2523d
tweak: remove redundant log
Gaxeer 98a2754
fix: add `COMSIG_MOB_LOGOUT` signal unregistering in `/datum/element/…
Gaxeer 67cdfba
refactor: move brainrot filter to config and other small tweaks
Gaxeer f154de7
feat: add lib `rust_utils` for regex text replace
Gaxeer 5b7c203
feat: replace `rust_g_ss220` to `rust_utils`
Gaxeer 37cab15
refactor: adjust to linter
Gaxeer de9a97d
fix: update rust-utils fetch CI
Gaxeer 9e77917
feat: update PreCompile.sh
Gaxeer 7563ea6
flower
Legendaxe 77b33e2
feat: add logging for brainrot filter
Gaxeer 515c241
Merge branch 'brainrot-filter' of https://github.com/Gaxeer/Paradise-…
Gaxeer a92f19f
fix: message replace returns!
Gaxeer bbdee5e
Merge branch 'master' of https://github.com/ss220club/Paradise-Remake…
Gaxeer 0b91551
fix: remove runtimes when reregistering signal
Gaxeer aca9014
Merge branch 'master' into brainrot-filter
Legendaxe d2a26d5
Update modular_ss220/speech_filter/code/speech_filter.dm
Gaxeer 4db2537
Merge branch 'master' into brainrot-filter
Legendaxe 27477f9
Merge branch 'master' into brainrot-filter
Furrior 1a7d4e0
Tabs
Furrior File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"brainrot_filter": [] | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/datum/modpack/rust_utils | ||
name = "Rust Utils" | ||
desc = "Набор утилит на rust" | ||
author = "furior, gaxeer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "_rust_utils.dm" | ||
|
||
#include "code/rust_utils.dm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef RUST_UTILS | ||
|
||
/* This comment bypasses grep checks */ /var/__rust_utils | ||
|
||
/proc/__detect_rust_utils() | ||
if(world.system_type == UNIX) | ||
if(fexists("./librust_utils.so")) | ||
// No need for LD_LIBRARY_PATH badness. | ||
return __rust_utils = "./librust_utils.so" | ||
else | ||
// It's not in the current directory, so try others | ||
return __rust_utils = "librust_utils.so" | ||
else | ||
return __rust_utils = "librust_utils" | ||
|
||
#define RUST_UTILS (__rust_utils || __detect_rust_utils()) | ||
#endif | ||
|
||
/// Gets the version of rust_utils | ||
/proc/rust_utils_get_version() return RUSTG_CALL(RUST_UTILS, "get_version")() | ||
|
||
#define rustutils_file_write_b64decode(text, fname) RUSTG_CALL(RUST_UTILS, "file_write")(text, fname, "true") | ||
|
||
#define rustutils_regex_replace(text, re, re_params, replacement) RUSTG_CALL(RUST_UTILS, "regex_replace")(text, re, re_params, replacement) | ||
|
||
#define rustutils_cyrillic_to_latin(text) RUSTG_CALL(RUST_UTILS, "cyrillic_to_latin")("[text]") | ||
#define rustutils_latin_to_cyrillic(text) RUSTG_CALL(RUST_UTILS, "latin_to_cyrillic")("[text]") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/datum/modpack/discord_link | ||
/datum/modpack/species_whitelist | ||
name = "Вайтлист на расы" | ||
desc = "Добавление вайтлиста на расы" | ||
author = "legendaxe" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/datum/modpack/speech_filter | ||
name = "Фильтр речи" | ||
desc = "Фильтрация речи игроков" | ||
author = "gaxeer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "_speech_filter.dm" | ||
|
||
#include "code/configuration.dm" | ||
#include "code/mob.dm" | ||
#include "code/speech_filter.dm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/datum/configuration_section/ss220_misc_configuration | ||
/// Whether or not player speech will be filtered | ||
var/enable_speech_filter = FALSE | ||
/// Set of player ckeys that bypass speech filter | ||
var/list/speech_filter_bypass = list() | ||
|
||
/datum/configuration_section/ss220_misc_configuration/load_data(list/data) | ||
. = ..() | ||
CONFIG_LOAD_BOOL(enable_speech_filter, data["enable_speech_filter"]) | ||
|
||
var/list/filter_bypass | ||
CONFIG_LOAD_LIST(filter_bypass, data["speech_filter_bypass"]) | ||
for(var/whitelisted_ckey in filter_bypass) | ||
speech_filter_bypass[ckey(whitelisted_ckey)] = TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/mob/living/Login() | ||
. = ..() | ||
AddElement(/datum/element/speech_filter, src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#define BRAINROT_FILTER_FILE "config/speech_filters/brainrot_filter.json" | ||
|
||
/datum/element/speech_filter | ||
element_flags = ELEMENT_DETACH_ON_HOST_DESTROY | ||
var/static/list/brainrot_notifications = list( | ||
"Почему у меня такой скудный словарный запас? Стоит сходить в библиотеку и прочесть книгу...", | ||
"Что, черт побери, я несу?", | ||
"Я в своём уме? Надо следить за языком.", | ||
"Неужели я не могу подобрать нужных слов? Позор мне..." | ||
) | ||
|
||
/datum/element/speech_filter/Attach(datum/target) | ||
. = ..() | ||
if(!isliving(target)) | ||
Gaxeer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ELEMENT_INCOMPATIBLE | ||
|
||
var/mob/mob_to_censor = target | ||
if(!mob_to_censor.client) | ||
return ELEMENT_INCOMPATIBLE | ||
|
||
RegisterSignal(mob_to_censor, COMSIG_MOB_SAY, PROC_REF(filter_speech), TRUE) | ||
RegisterSignal(mob_to_censor, COMSIG_MOB_LOGOUT, PROC_REF(Detach)) | ||
Gaxeer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/datum/element/speech_filter/Detach(datum/source, force) | ||
. = ..() | ||
UnregisterSignal(source, COMSIG_MOB_SAY) | ||
UnregisterSignal(source, COMSIG_MOB_LOGOUT) | ||
|
||
/datum/element/speech_filter/proc/filter_speech(mob/talker, list/speech_args) | ||
if(!GLOB.configuration.ss220_misc.enable_speech_filter || can_bypass_filter(talker)) | ||
return | ||
|
||
var/message = speech_args[SPEECH_MESSAGE] | ||
if(!length(message)) | ||
return | ||
|
||
if(message[1] == "*") | ||
return | ||
|
||
var/brainrot_regex = get_brainrot_filter_regex() | ||
if(!brainrot_regex) | ||
return | ||
|
||
var/original_message = copytext(message, 1) | ||
message = rustutils_regex_replace(message, brainrot_regex, "i", "цветочек") | ||
if(original_message == message) | ||
return | ||
|
||
speech_args[SPEECH_MESSAGE] = message | ||
addtimer(CALLBACK(talker, TYPE_PROC_REF(/mob, emote), "drool"), 0.3 SECONDS) | ||
to_chat(talker, span_sinister(pick(brainrot_notifications))) | ||
log_and_message_admins("[key_name(talker)] has attempted to say forbidden word. His message was: [original_message]") | ||
|
||
/datum/element/speech_filter/proc/get_brainrot_filter_regex() | ||
if(!fexists(BRAINROT_FILTER_FILE)) | ||
return | ||
|
||
var/static/list/filters = json_load(BRAINROT_FILTER_FILE)["brainrot_filter"] | ||
if(!length(filters)) | ||
return list() | ||
|
||
var/static/brainrot_regex | ||
if(!brainrot_regex) | ||
var/list/unique_filters = list() | ||
unique_filters |= filters | ||
brainrot_regex = unique_filters.Join("|") | ||
|
||
return brainrot_regex | ||
|
||
/datum/element/speech_filter/proc/can_bypass_filter(mob/mob_to_check) | ||
return mob_to_check.client.ckey in GLOB.configuration.ss220_misc.speech_filter_bypass | ||
|
||
#undef BRAINROT_FILTER_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,32 +9,20 @@ set -x | |
#need to switch to game dir for Dockerfile weirdness | ||
original_dir=$PWD | ||
cd "$1" | ||
. dependencies.sh | ||
. _build_dependencies.sh | ||
cd "$original_dir" | ||
|
||
git config --global user.name | ||
if [ $? -eq 1 ] | ||
then | ||
git config --global user.name "paradise_tgs_script" | ||
fi | ||
|
||
git config --global user.email | ||
if [ $? -eq 1 ] | ||
then | ||
git config --global user.email "[email protected]" | ||
fi | ||
|
||
# update rust-g | ||
if [ ! -d "rust-g" ]; then | ||
echo "Cloning rust-g..." | ||
git clone https://github.com/ParadiseSS13/rust-g | ||
cd rust-g | ||
~/.cargo/bin/rustup target add i686-unknown-linux-gnu | ||
echo "Cloning rust-g..." | ||
git clone https://github.com/ParadiseSS13/rust-g | ||
cd rust-g | ||
~/.cargo/bin/rustup target add i686-unknown-linux-gnu | ||
else | ||
echo "Fetching rust-g..." | ||
cd rust-g | ||
git fetch | ||
~/.cargo/bin/rustup target add i686-unknown-linux-gnu | ||
echo "Fetching rust-g..." | ||
cd rust-g | ||
git fetch | ||
~/.cargo/bin/rustup target add i686-unknown-linux-gnu | ||
fi | ||
|
||
echo "Deploying rust-g..." | ||
|
@@ -43,25 +31,24 @@ git reset --hard "$RUSTG_VERSION" | |
cd paradise-rust-g | ||
env PKG_CONFIG_ALLOW_CROSS=1 ~/.cargo/bin/cargo build --release --features all --target=i686-unknown-linux-gnu | ||
mv target/i686-unknown-linux-gnu/release/librust_g.so "$1/librust_g.so" | ||
cd .. | ||
cd ../../ | ||
|
||
if [ ! -d "rust-g-tg" ]; then | ||
echo "Cloning rust-g..." | ||
git clone https://github.com/ss220club/rust-g-tg | ||
cd rust-g-tg | ||
~/.cargo/bin/rustup target add i686-unknown-linux-gnu | ||
if [ ! -d "rust-utils" ]; then | ||
echo "Cloning rust-utils..." | ||
git clone https://github.com/ss220club/rust-utils | ||
cd rust-utils | ||
~/.cargo/bin/rustup target add i686-unknown-linux-gnu | ||
else | ||
echo "Fetching rust-g..." | ||
cd rust-g-tg | ||
git fetch | ||
~/.cargo/bin/rustup target add i686-unknown-linux-gnu | ||
echo "Fetching rust-utils..." | ||
cd rust-utils | ||
git fetch | ||
~/.cargo/bin/rustup target add i686-unknown-linux-gnu | ||
fi | ||
|
||
echo "Deploying rust-g ss220..." | ||
echo "Deploying rustutils..." | ||
RUSTFLAGS="-C target-cpu=native" | ||
env PKG_CONFIG_ALLOW_CROSS=1 ~/.cargo/bin/cargo build --release --features all --target=i686-unknown-linux-gnu | ||
rm -f "$original_dir/../GameStaticFiles/librust_g_ss220.so" | ||
mv target/i686-unknown-linux-gnu/release/librust_g.so "$original_dir/../GameStaticFiles/librust_g_ss220.so" | ||
env PKG_CONFIG_ALLOW_CROSS=1 ~/.cargo/bin/cargo build --release --all-features --target=i686-unknown-linux-gnu | ||
mv target/i686-unknown-linux-gnu/release/librust_utils.so "$1/librust_utils.so" | ||
cd ../../ | ||
|
||
echo "Deploying MILLA..." | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Возможно стоит добавить проверку по рангу
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Может быть