aboutsummaryrefslogtreecommitdiff
path: root/.weechat
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2020-10-29 15:16:45 +0100
committerPatrick Spek <p.spek@tyil.nl>2021-08-14 11:59:44 +0200
commitdee6755aa52fb714408727123d7f1069b779e930 (patch)
tree0ebf23ee8be5c8d6a100f451f65f4b30ad583e96 /.weechat
parent9c5780535b1b99bf9a4bb48ca8e185280a78304c (diff)
Add bad word filter
Diffstat (limited to '.weechat')
l---------.weechat/perl/autoload/bad-word-filter.pl1
-rw-r--r--.weechat/perl/bad-word-filter.pl50
2 files changed, 51 insertions, 0 deletions
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;
+}