From dee6755aa52fb714408727123d7f1069b779e930 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Thu, 29 Oct 2020 15:16:45 +0100 Subject: Add bad word filter --- .weechat/perl/autoload/bad-word-filter.pl | 1 + .weechat/perl/bad-word-filter.pl | 50 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 120000 .weechat/perl/autoload/bad-word-filter.pl create mode 100644 .weechat/perl/bad-word-filter.pl (limited to '.weechat') diff --git a/.weechat/perl/autoload/bad-word-filter.pl b/.weechat/perl/autoload/bad-word-filter.pl new file mode 120000 index 0000000..548d7e6 --- /dev/null +++ b/.weechat/perl/autoload/bad-word-filter.pl @@ -0,0 +1 @@ +../bad-word-filter.pl \ No newline at end of file diff --git a/.weechat/perl/bad-word-filter.pl b/.weechat/perl/bad-word-filter.pl new file mode 100644 index 0000000..4d6b9b1 --- /dev/null +++ b/.weechat/perl/bad-word-filter.pl @@ -0,0 +1,50 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use utf8; + +weechat::register("rizon_chat_filter", "tyil", "0.1", "AGPL-3.0", "Do your part in keeping Christian channels safe and friendly", "", ""); +weechat::hook_modifier("input_text_for_buffer", "catch_send", ""); + +sub catch_send { + my ($data, $modifier_name, $buffer, $msg) = @_; + my $buffer_name = weechat::buffer_get_string($buffer, 'name'); + + # These are the channels (or really, buffers) on which self-harm + # protections should be enabled. + my @christian_channels = ( + 'freenode.##t', + 'rizon.#chat', + ); + + # These are the words that may not be spoken. + my @bad_words = ( + 'nigger', + 'cuck', + ); + + # First, the message can be returned as is unless this message is sent + # into a Christian channel. + my $christian_context = 0; + + for my $channel (@christian_channels) { + if ($channel eq $buffer_name) { + $christian_context = 1; + } + } + + return $msg unless $christian_context; + + # Next, see if there are any bad words in this message. + for my $bad_word (@bad_words) { + next unless $msg =~ m/$bad_word/; + + # BAD WORD DETECTED + weechat::print($buffer, 'The power word "'.$bad_word.'" is unfit for this channel.'); + return ""; + } + + # It's a safe message, just return it. + return $msg; +} -- cgit v1.1