YouHaveTrouble / Censura

Advanced censorship plugin for minecraft servers
GNU General Public License v3.0
9 stars 5 forks source link

[suggestion] add a new action for warning staff members and more #8

Open Dawlnken opened 3 months ago

Dawlnken commented 3 months ago

It would be nice to have an action that alerts online staff members when a player swears. Highlighting the curse word typed.

Also, would be really cool to add support for discord webhooks, for offline staff members to keep track of chat violations.

Example config if this was added:

# Should server operators bypass the filters?
op-bypass: true

# Should players be denied to join if their name contains bad words?
kick-on-bad-name: true

# Which events should be checked for bad words?
checks:
  chat: true
  sign: true
  book: true
  command: true
  anvil-name: true
  nametag-use: true

# Should detections that contain filtered words be logged in console
log-detections: true

# Commands of which arguments should be checked.
# It's recommended to list all private message commands and their aliases
# and every command that allows changing item name and etc.
filtered-commands:
  - msg
  - w
  - say
  - me

# filter messages based on characters they contain. If message contains characters not
# present in regex, it will be cancelled.
prefilter:
  enabled: false
  regex: "[\\p{L}0-9\\s;.\\/<>()!@#$%^&*|:~+=\\-_,?\"'\\[\\]]+"
  failed: "Censura - Your input contained disallowed characters."

# These characters are replaced by the character on the right before processing.
replacements:
  '0': o
  '1': i
  '3': e
  '4': a
  '5': s
  '7': t
  '9': g
  '$': s
  '@': a

# Check if the current chat message is similiar to the messages sent before
similarity:
  # Should feature be anabled?
  enabled: false
  # How many messages back to check
  message-amount: 3
  # Percentage of how similiar messages should be to be flagged as similar to previous ones
  threshold: 80
  actions:
    - "message: Censura - Stop sending spammy messages, %player%!"

##### FILTERS
# Filters are processed in order from top to bottom
# You can have an unlimited number of filters.
###############################################################
# Each filter has a list of "matches". These are words that are checked for the filter.
# Types of matches:
#   - "fullword" Checks if the sentence contains this word. It must be surrounded by spaces.
#                Besides that, the filter is smart and will ignore any characters in between the word.
#                You can use the * character to bypass the limitation of needing a space: "test*" will match on "testsomething"
#   - "contain"  Checks if the sentence contains the string, the string may be part of another word.
#                Will ignore spaces inside the word unless they're used in an obviously spammy way.
#   - "regex"    Match a simple regex on the string. No smartness involved.
# By default the "fullword" match type is used.

###############################################################
# Each filter can have an unlimited number of "actions". Possible "action" types:
#   - "alert:<message>" - alert staff members with the permission censura.alerts when someone triggers the filter 
#   - "message: <message>" - sends a message to player who triggered the filter
#   - "command: <command>" - executes command as console.
# Placeholders available for all actions:
# %player% - name of the player who triggered the filter
# %sentence% - word or sentence triggered

filter:
  severe:
    action:
      - "command: ban %player% Censura - Using offensive words."
      - "alert: Censura - %player% typed %sentence% !"
    match:
      - nigger
      - nibber
      - niga
      - niba
      - hitler did nothing wrong
      - heil hitler
  normal:
    action:
      - "command: kick %player% Censura - Stop using curse words!"
      - "alert: Censura - %player% typed %sentence% !"
    match:
      - fuck: "contain"
      - bitch
      - faggot
      - tranny
      - trannie
      - gay is a sin
      - gay is sin
  light:
    action:
      - "message: Censura - Stop using bad words, %player%!"
      - "alert: Censura - %player% typed %sentence% !"
    match:
      - sex
      - porn: "contain"
      - shit: "contain"
      - fag: "contain"
      - nigg: "contain"

discord-webhook:
  # Whether or not Discord Webhook should be enabled
  enabled: false
  # Paste the URL to your webhook here. For how to create a webhook, please see https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
  url: WEBHOOK URL HERE
  # The avatar for the webhook
  avatar: https://cdn.modrinth.com/data/1bHrk3Qj/fc8befa6db65ff97f878f6a47f124135a0a11b0f.jpeg # Plugin logo, you can change it to whatever you want
  # Thumbnail for the webhook
  thumbnail: http://cravatar.eu/avatar/%player%/64.png #Will show the player head
  # Colors for the webhook (use a website like https://www.rapidtables.com/web/color/RGB_Color.html to pick colors)
  color-r: 0
  color-g: 0
  color-b: 0
  # Username of the webhook
  username: Censura
  # Title of the webhook
  title: Censura - Alerts
  # Description of the webhook
  description: '**%player%** just cursed: %sentence%' 
  # Content will send text outside of the embed, so you can tag roles or people for example.
  content: ''

# Messages used by the plugin
messages:
  no-permission: "Censura - &cYou don't have permission to do this."
  no-such-command: "Censura - &cThere is no such command."
  config-reloaded: "Censura - &aConfiguration reloaded."
  kick-bad-name: "Censura\n&cYour name contains bad words!"
YouHaveTrouble commented 3 months ago

sadly, the plugin does not currently have a functionality to extract the matches that lead to cancelling the message. To add anything based on that would likely be a rewrite of more than half of the plugin