Git Product home page Git Product logo

filterplus's Introduction

FilterPlus

Primarily a chat filter, also censors content via API.

Copyright (c) 2023 monk

Details

  • Blacklisted words indexed by pattern.
  • Robust Whitelist.
  • Censors words with asterisk(*).
  • Lowers casing in messages exceeding max_caps setting.
  • Support for Chat rank/tags.
  • Mention player by name sends green text messages.
  • Filter list management and chat moderation commands.
  • Removes URL links.
  • API will return true with the word censored by asterisk.

Chat commands

Mute players from using public chat, does not mute private messaging. Applied to players by IP address, so any players currently online or alt accounts to join will be muted until lifted. Can be used on offline players if they were online recently (approx 1 hour).

  • Mute/Unmute player(s) by associated IP (requires mute priv)
    • Default is 2 minutes, two hour max
/mute <playername> [<minutes>]
/unmute <playername>

Filter List management

  • Manage mod_storage filter lists (requires blacklist priv)
/filter <blacklist>|<whitelist>|<delete>|<search> <string>
  • Add word to whitelist, or blacklist (will automatically remove word from opposite list) /filter whitelist word /filter blacklist word

  • Delete word from all filter lists (bug: it doesn't) /filter delete word

  • Search for word in either filter lists /filter search word

  • Save filter lists to mod_storage.

  • Run this after making changes to the mod_storage filters via command

    • To do: Needs update to only save words in mod storage
/filter_save
  • Reload the filter lists.
    • Run this after modifying the word filter files whitelist.lua or blacklist.lua.
/filter_reload

Message Tags

Player nametag in chat default format is: <PlayerName>.

Supported tags from mods if available: Ranks, Factions, Exp.

The minetest.conf setting must be true, and pass required values.

  • filterplus_ranks: {Rank} requires a string and ColorString
  • filterplus_factions: [Faction] requires a string and ColorString
  • filterplus_exp: (Exp) requires integer or string

Tag order is: {Rank}[Faction](Exp)<PlayerName> message

API

Not limited to chat messages. Strings from any mod can be checked against filter api:

filterplus_api.check_word(string)

This will return with the string, censored or not, with boolean:

return "This **** is censored", true

return "This word is not censored", false

Additional Info

  • UTF-16 or non-ASCII characters

Adding words by command containing UTF-8 characters are saved to mod_storage as UTF reference codes (\u00f). This will cause many false-positives.

  • Pattern matches from blacklist are ordered

Filter lists are sorted by numerical index, not alphabetically. This allows for word priority when list checking, for example, if luck and luk are blacklisted, saying lucky will catch the former first.

If tex is a blacklisted word, all instances containing tex are filtered, such as text, context, contextual, etc. This means blacklisting these branch words is redundant, root words should be sufficient.

Current Version 0.1.4

filterplus's People

Contributors

monk-afk avatar

Stargazers

 avatar

Watchers

 avatar

filterplus's Issues

additional check for evasion technique

to filter commonly used evasion technique, possibly merge the proceeding word with the current one after removing symbol. for example:

"this is a test" would check for: "thisis", "isa" "atest", as well as the individual words.

this will cause some false-positives, the main one being "puta", example: "I put a block here". In tests using str.find without spaces "puta" was found 1081 time out of the 4890 blacklist hits, more than "fuck" which was found 1024 times.

chat messages:       4205567
words total:         13178334
blacklist items:     413
filter hits:         4890
clock time:          53.435444

if the added checks aren't too costly, here is the most recent profiler dump:

2024-02-11 07:29:17: ACTION[Server]: Values below show absolute/relative times spend per server step by the instrumented function.
A total of 2306385 samples were taken

 instrumentation           |   min µs |   max µs |   avg µs | min % | max % | avg %
-------------------------- | -------- | -------- | -------- | ----- | ----- | ------
filterplus:                |        0 |    72973 |       16 |   0.0 |  92.3 |   0.3
  - on_leaveplayer[1] .... |        1 |      788 |        4 |   0.0 |  19.1 |   0.1
  - on_chat_message[1] ... |        5 |    72973 |      648 |   0.0 |  92.3 |  13.0
  - /mute ................ |      289 |      361 |      332 |   1.2 |  18.9 |  10.5
  - on_joinplayer[1] ..... |        1 |     2779 |        4 |   0.0 |   8.1 |   0.0

another string manipulation needed it removing repeating characters. no english word (that i know of) uses more than two repeating letters, so removing the additional repeats would be handy.

a quick writeup which mostly works:

local function remove_repeating(message)
	return message:gsub("([%S]+)([%S])%1", "%2")  -- keep doubled chars
end

print(
	remove_repeating("hi assume this teeeeeesssssttttt aggregate okkkk")
)

bug with the above script is: for odd numbered repeats: 55555 it leaves one character, and with even numbered repeats: 4444 it leaves two characters, so many word variants would have to be added to blacklist, ex: one, oone, oonnee, onnee, etc.. this is not efficient but it's a starting point anyway

add ability to ignore public chat or individual players

/ignore_all to ignore the public chats, but still can receive direct message

/ignore <playername> to ignore specific player

if these functions are enabled, the player shouldn't be able to send to public chat/ignored player

change load/save from mod_storage

  • make it so the word-list files are loaded first, then the mod storage.

  • only save list items added by the /filter commands to mod_storage, don't save words already in the *list.lua files.

  • update /reload_filter to this change

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.