A simple chat word filter.
Find a file
2020-04-28 07:28:12 +05:30
textures Add warning formspec on first violation 2018-02-05 23:03:19 -08:00
.gitignore Add kick above certain number of violations (#2) 2018-02-02 09:07:41 -08:00
.luacheckrc Fix conflict with chat commands 2018-02-05 23:03:19 -08:00
depends.txt Add support for the email mod 2018-02-05 23:03:19 -08:00
description.txt Initial commit. 2017-11-04 21:37:49 -07:00
filters.lua Implement an API; add support for custom filters 2020-04-28 07:28:12 +05:30
init.lua Implement an API; add support for custom filters 2020-04-28 07:28:12 +05:30
LICENSE Add warning formspec on first violation 2018-02-05 23:03:19 -08:00
mod.conf Add desc. and depends to mod.conf 2018-06-29 23:23:52 -07:00
readme.md Implement an API; add support for custom filters 2020-04-28 07:28:12 +05:30
screenshot.png Add screenshot. 2018-05-28 17:49:30 -07:00

filter mod

This mod adds a chat filter API that can be used to register custom chat filters. As of now a bad words filter has been implemented. There is no default word list, and adding words to the filter list is done through the /word_filter chat command, which requires server priv.

The /word_filter chat command can add, remove or list words. The words are stored in mod_storage, which means that this mod requires 0.4.16 or above to function.

If a player triggers a filter, they are muted for 1 minute. After that, their shout privilege is restored. If they leave, their shout privilege is still restored, but only after the time expires, not before.

API

Custom filter registration

  • filter.register_filter(name, func(playername, message))
    • Takes a name and a two-parameter function
    • name is the name of the filter, which is currently unused, except for indexing.
    • playername and message hold the name of the player and the message they sent, respectively.
    • func should return a relevant warning when triggered. e.g. "Watch your language!", and nil when message has passed the check.

Callbacks

  • filter.register_on_violation(func(name, message, violations))
    • violations is the value of the player's violation counter - which is incremented on a violation, and halved every 10 minutes.
    • Return true if you've handled the violation. No more callbacks will be executation, and the default behaviour (warning/mute/kick) on violation will be skipped.

Methods

  • filter.import_file(path)
    • Input bad words from a file (path) where each line is a new word.
  • filter.check_message(name, message)
    • Checks message for violation. Returns true if bad, false if ok. If it returns true, the message is not sent filter.on_violation is called.
  • filter.on_violation(name, message)
    • Increments violation count, runs callbacks, and punishes the players.
  • filter.mute(name, duration)
  • filter.show_warning_formspec(name)