chiark / gitweb /
check responses are in right phase for article; implement notice_processed
[inn-innduct.git] / control / modules / version.pl
1 ##  $Id: version.pl 4932 2001-07-19 00:32:56Z rra $
2 ##
3 ##  version control message handler.
4 ##
5 ##  Copyright 2001 by Marco d'Itri <md@linux.it>
6 ##
7 ##  Redistribution and use in source and binary forms, with or without
8 ##  modification, are permitted provided that the following conditions
9 ##  are met:
10 ##
11 ##   1. Redistributions of source code must retain the above copyright
12 ##      notice, this list of conditions and the following disclaimer.
13 ##
14 ##   2. Redistributions in binary form must reproduce the above copyright
15 ##      notice, this list of conditions and the following disclaimer in the
16 ##      documentation and/or other materials provided with the distribution.
17
18 use strict;
19
20 sub control_version {
21     my ($par, $sender, $replyto, $site, $action, $log, $approved,
22         $headers, $body) = @_;
23     my ($where) = @$par;
24
25     my $version = $inn::version || '(unknown version)';
26
27     if ($action eq 'mail') {
28         my $mail = sendmail("version $sender");
29         print $mail <<END;
30 $sender has requested information about your
31 news software version.
32
33 If this is acceptable, type:
34   echo "InterNetNews $version" | $inn::mailcmd -s "version reply from $inn::pathhost" $replyto
35
36 The control message follows:
37
38 END
39         print $mail map { s/^~/~~/; "$_\n" } @$headers;
40         print $mail "\n";
41         print $mail map { s/^~/~~/; "$_\n" } @$body;
42         close $mail or logdie("Cannot send mail: $!");
43     } elsif ($action eq 'log') {
44         if ($log) {
45             logger($log, "version $sender", $headers, $body);
46         } else {
47             logmsg("version $sender");
48         }
49     } elsif ($action =~ /^(doit|doifarg)$/) {
50         if ($action eq 'doifarg' and $where ne $inn::pathhost) {
51             logmsg("skipped version $sender");
52             return;
53         }
54         sendmail("version reply from $inn::pathhost", $replyto,
55             [ "InterNetNews $version\n" ]);
56
57         logger($log, "version $sender to $replyto", $headers, $body) if $log;
58     }
59 }
60
61 1;