1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
weechat::register("bad_word_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',
'rizon.#stew',
);
# These are the words that may not be spoken.
my @bad_words = (
'cuck',
'fag',
'kike',
'negro',
'nigga',
'nigger',
);
# 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;
}
|