1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut-pastebin synced 2025-06-07 22:26:01 -04:00

Dynamic banned word list

This commit is contained in:
Ryan Voots 2017-05-11 17:21:34 -04:00
parent d121b3ea28
commit 4f80f12172
2 changed files with 13 additions and 8 deletions

View file

@ -19,6 +19,7 @@ sub routes {
$route->(post => '/api/v1/paste' => 'api_post_paste'); $route->(post => '/api/v1/paste' => 'api_post_paste');
$route->(get => '/api/v1/languages' => 'api_get_languages'); $route->(get => '/api/v1/languages' => 'api_get_languages');
$route->(get => '/api/v1/channels' => 'api_get_channels'); $route->(get => '/api/v1/channels' => 'api_get_channels');
$route->(get => '/api/v1/re' => 'api_get_re');
} }
sub api_get_paste { sub api_get_paste {
@ -61,7 +62,7 @@ sub api_post_paste {
# warn "I thought this was spam! $type"; # warn "I thought this was spam! $type";
# } else { # } else {
if ($channel) { # TODO config for allowing announcements if ($channel) { # TODO config for allowing announcements
my $words = qr/nigger|jew|spic|tranny|trannies|fuck|shit|piss|cunt|asshole|hitler|klan|klux/i; my $words = $c->paste->banned_word_list_re;
unless ($code =~ $words || $who =~ $words || $desc =~ $words) { unless ($code =~ $words || $who =~ $words || $desc =~ $words) {
$c->perlbot->announce($channel, $who, substr($desc, 0, 40), $c->req->url->base()."/p/$id"); $c->perlbot->announce($channel, $who, substr($desc, 0, 40), $c->req->url->base()."/p/$id");
} }
@ -100,4 +101,11 @@ sub api_get_channels {
]}); ]});
}; };
sub api_get_re {
my $c=shift;
use Data::Dumper;
$c->render(text => Dumper($c->paste->banned_word_list_re));
}
1; 1;

View file

@ -60,15 +60,12 @@ sub get_paste {
sub banned_word_list_re { sub banned_word_list_re {
my $self = shift; my $self = shift;
my $data = $self->dbh->selectall_arrayref("SELECT word FROM wordlist WHERE deleted <> 1"); my $data = $self->dbh->selectall_arrayref("SELECT word FROM banned_words WHERE deleted <> 1");
#return $re; my $re_str = join '|', map {quotemeta $_->[0]} @$data;
} my $re = qr/($re_str)/i;
sub add_banned_word { return $re;
my ($self, $word, $who) = @_;
# $self->
} }
1; 1;