1 |
|
#!/usr/bin/perl |
2 |
|
|
3 |
=head1 NAME |
=head1 NAME |
4 |
|
|
17 |
use Getopt::Long; |
use Getopt::Long; |
18 |
$NNTP_SERVER = 'localhost'; |
$NNTP_SERVER = 'localhost'; |
19 |
$Bunshin::DEBUG = 0; |
$Bunshin::DEBUG = 0; |
20 |
|
my $VERBOSE; |
21 |
my $directory = './module/'; |
my $directory = './module/'; |
22 |
my $posted_log = '.posted'; |
my $posted_log = '.posted'; |
23 |
GetOptions ( |
GetOptions ( |
25 |
'module-dir=s' => \$directory, |
'module-dir=s' => \$directory, |
26 |
'nntp-server=s' => \$NNTP_SERVER, |
'nntp-server=s' => \$NNTP_SERVER, |
27 |
'posted-log=s' => \$posted_log, |
'posted-log=s' => \$posted_log, |
28 |
|
verbose => \$VERBOSE, |
29 |
) or die; |
) or die; |
30 |
|
|
31 |
sub dprint (@); |
sub dprint (@); |
32 |
|
sub vprint (@); |
33 |
binmode STDOUT; |
binmode STDOUT; |
34 |
|
|
35 |
opendir DIR, $directory; |
opendir DIR, $directory; |
52 |
} |
} |
53 |
|
|
54 |
for (@module) { |
for (@module) { |
55 |
dprint $_; |
vprint $_; |
56 |
my $module = "Suikawari::$_"; |
my $module = "Suikawari::$_"; |
57 |
require "$_.sb"; |
require "$_.sb"; |
58 |
my $b = new Bunshin; |
my $b = new Bunshin; |
97 |
dprint "Posting Message..."; |
dprint "Posting Message..."; |
98 |
my @m = map {$_."\n"} split /\x0D\x0A/, $msg; |
my @m = map {$_."\n"} split /\x0D\x0A/, $msg; |
99 |
my $r = $nntp->post (@m); |
my $r = $nntp->post (@m); |
100 |
dprint ${*$nntp}{'net_cmd_code'}, @{${*$nntp}{'net_cmd_resp'}}; |
vprint ${*$nntp}{'net_cmd_code'}, @{${*$nntp}{'net_cmd_resp'}}; |
101 |
unless ($r) { |
unless ($r) { |
102 |
close_nntp ($nntp); |
close_nntp ($nntp); |
103 |
die; |
die; |
106 |
|
|
107 |
sub open_nntp () { |
sub open_nntp () { |
108 |
require Net::NNTP; |
require Net::NNTP; |
109 |
dprint "Connecting to $NNTP_SERVER..."; |
vprint "Connecting to $NNTP_SERVER..."; |
110 |
my $nntp = Net::NNTP->new ($NNTP_SERVER) or die "$0: open_nntp: $!"; |
my $nntp = Net::NNTP->new ($NNTP_SERVER) or die "$0: open_nntp: $!"; |
111 |
dprint ${*$nntp}{'net_cmd_code'}, @{${*$nntp}{'net_cmd_resp'}}; |
vprint ${*$nntp}{'net_cmd_code'}, @{${*$nntp}{'net_cmd_resp'}}; |
112 |
$nntp; |
$nntp; |
113 |
} |
} |
114 |
|
|
116 |
my $nntp = shift; |
my $nntp = shift; |
117 |
return unless ref $nntp; |
return unless ref $nntp; |
118 |
$nntp->quit; |
$nntp->quit; |
119 |
dprint ${*$nntp}{'net_cmd_code'}, @{${*$nntp}{'net_cmd_resp'}}; |
vprint ${*$nntp}{'net_cmd_code'}, @{${*$nntp}{'net_cmd_resp'}}; |
120 |
} |
} |
121 |
|
|
122 |
sub dprint (@) { |
sub dprint (@) { |
124 |
print map {/\n$/s? $_: $_."\n"} @_ if $Bunshin::DEBUG; |
print map {/\n$/s? $_: $_."\n"} @_ if $Bunshin::DEBUG; |
125 |
} |
} |
126 |
|
|
127 |
|
sub vprint (@) { |
128 |
|
print shift, ' ' if ($VERBOSE || $Bunshin::DEBUG) && @_ > 1; |
129 |
|
print map {/\n$/s? $_: $_."\n"} @_ if $VERBOSE || $Bunshin::DEBUG; |
130 |
|
} |
131 |
|
|
132 |
package posted_log_ns; |
package posted_log_ns; |
133 |
use vars qw/%OPTION/; |
use vars qw/%OPTION/; |
134 |
|
|