chiark / gitweb /
Split nameIsInList into nameIsInListRegexp (for most things) and nameIsInListExactly...
[modbot-mtm.git] / stump / bin / robomod.pl
1 #!/usr/bin/perl
2 #
3 # Collection of common functions
4 #
5
6 $MNG_ROOT = $ENV{'MNG_ROOT'} || die "Root dir for moderation not specified";
7
8 ###################################################################### checkAck
9 # checks if poster needs ack
10 sub nameIsInListRegexp {
11   local( $listName ) = pop( @_ );
12   local( $address ) = pop( @_ );
13
14   local( $item );
15
16   $Result = 0;
17
18   open( LIST, "$MNG_ROOT/data/$listName" );
19
20   while( $item = <LIST> ) {
21
22     chop $item;
23
24     next if $item =~ /^ *$/;
25
26     if( eval { $address =~ /$item/i; } ) {
27       $Result = $item;
28     }
29   }
30
31   close( LIST );
32
33   return $Result;
34 }
35
36 sub nameIsInListExactly {
37   local( $listName ) = pop( @_ );
38   local( $address ) = pop( @_ );
39
40   local( $item );
41
42   $Result = 0;
43
44   open( LIST, "$MNG_ROOT/data/$listName" );
45
46   while( $item = <LIST> ) {
47
48     chop $item;
49
50     next if $item =~ /^ *$/;
51
52     if( "\L$address" eq "\L$item" ) {
53       $Result = $item;
54     }
55   }
56
57   close( LIST );
58
59   return $Result;
60 }
61
62 sub logAction {
63   my $msg = pop( @_ );
64
65   print STDERR $msg . "\n";
66 }
67
68
69 ######################################################################
70 # Setting variables
71
72 if( defined( $ENV{'STUMP_PARANOID_PGP'} ) ) {
73   $paranoid_pgp = $ENV{'STUMP_PARANOID_PGP'}  eq "YES";
74 } else {
75    $paranoid_pgp = 0;
76 }
77
78 1;