]> the.earth.li Git - htag.git/blob - plugins/06marknlard
a6c9c8259fb15abaf1bd2ba4f4b1e2f6d9a1cc68
[htag.git] / plugins / 06marknlard
1 #!/usr/bin/perl -w
2
3 # Copyright (C) 2000-2001 Simon Huggins
4 # marknlard outputs Mark 'n Lard style attributions
5
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by the Free
8 # Software Foundation; either version 2 of the License, or (at your option)
9 # any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 # for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc., 59
18 # Temple Place, Suite 330, Boston, MA 02111-1307  USA
19
20 # Outputs attribution to tmpdir/M
21 # Therefore replaces @M... in sigs via merge.
22
23 use strict;
24
25 return if not defined $cfg{'attributions'};
26
27 my @found = scansigfile("M");
28
29 return if not @found;
30
31 my (@attributions);
32
33 # srand( time() ^ ($$ + ($$ << 15) )); # Since 5.004 not required
34
35 open(HANDLE, "<$cfg{'attributions'}") or htagdie "Could not open $cfg{'attributions'}: $!\n";
36 @attributions=<HANDLE>;
37 close(HANDLE);
38
39 open(OUT, ">$cfg{'tmpdir'}/M") or htagdie "$0: Could not open $cfg{'tmpdir'}/M: $!\n";
40 reg_deletion("$cfg{'tmpdir'}/M");
41 foreach my $f (@found) {
42         my @f = @{$f};
43         my $recursion = 0;
44         while ($recursion < 30) {
45                 $recursion++;
46                 my $attr = pickone();
47                 if (length $attr <= $f[1]) {
48                         print OUT chunksizealign($attr, $f[1], $f[2]),"\n";
49                         $recursion = 255;
50                 }
51         }
52         if ($recursion != 255) {
53                 htagdie "Recursed too much trying to find attribution <= $f[1].\nPerhaps your attributions aren't short enough?\n";
54         }
55 }
56 close(OUT);
57 return;
58
59 sub pickone {
60         my $attribution = $attributions[rand(@attributions)];
61         chomp $attribution;
62         my ($who,$gender) = split(":",$attribution);
63         return "Is it $who, Mark?  Sounds just like $gender.";
64 }