]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/Spamcheck.pm
solver: support sha256 coderepos
[public-inbox.git] / lib / PublicInbox / Spamcheck.pm
1 # Copyright (C) 2018-2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 # Spamchecking used by -watch and -mda tools
5 package PublicInbox::Spamcheck;
6 use strict;
7 use warnings;
8
9 sub get {
10         my ($cfg, $key, $default) = @_;
11         my $spamcheck = $cfg->{$key};
12         $spamcheck = $default unless $spamcheck;
13
14         return if !$spamcheck || $spamcheck eq 'none';
15
16         if ($spamcheck eq 'spamc') {
17                 $spamcheck = 'PublicInbox::Spamcheck::Spamc';
18         }
19         if ($spamcheck =~ /::/) {
20                 eval "require $spamcheck";
21                 return $spamcheck->new;
22         }
23         warn "unsupported $key=$spamcheck\n";
24         undef;
25 }
26
27 1;