/[suikacvs]/messaging/suikawari/wari.pl
Suika

Diff of /messaging/suikawari/wari.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by wakaba, Sun Jun 16 10:49:10 2002 UTC revision 1.2 by wakaba, Sun Jun 16 11:06:45 2002 UTC
# Line 1  Line 1 
1    #!/usr/bin/perl
2    
3  =head1 NAME  =head1 NAME
4    
# Line 16  use Message::Header; Line 17  use Message::Header;
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 (
# Line 23  GetOptions ( Line 25  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;
# Line 48  close LOG; Line 52  close LOG;
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;
# Line 93  sub send_msg ($$) { Line 97  sub send_msg ($$) {
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;
# Line 102  sub send_msg ($$) { Line 106  sub send_msg ($$) {
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    
# Line 112  sub close_nntp ($) { Line 116  sub close_nntp ($) {
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 (@) {
# Line 120  sub dprint (@) { Line 124  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    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24