/[notice-sender]/trunk/sender.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/sender.pl

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

revision 22 by dpavlin, Sun May 15 21:52:56 2005 UTC revision 29 by dpavlin, Mon May 16 20:58:44 2005 UTC
# Line 16  sender.pl - command line notify sender u Line 16  sender.pl - command line notify sender u
16   sender.pl --queue[=mylist message.txt]   sender.pl --queue[=mylist message.txt]
17   sender.pl --send=mylist   sender.pl --send=mylist
18    
19    In C</etc/aliases> something like:
20    
21     mylist: "| /path/to/sender.pl --inbox=mylist"
22    
23  =head2 Command options  =head2 Command options
24    
25  =over 20  =over 20
# Line 29  my $add_opt; Line 33  my $add_opt;
33  my $queue_opt;  my $queue_opt;
34  my $send_opt;  my $send_opt;
35  my $email_opt;  my $email_opt;
36    my $inbox_opt;
37    
38  my $result = GetOptions(  my $result = GetOptions(
39          "list:s" => \$list_opt,          "list:s" => \$list_opt,
40          "add=s" => \$add_opt,          "add=s" => \$add_opt,
41          "queue:s" => \$queue_opt,          "queue:s" => \$queue_opt,
42          "send:s" => \$send_opt,          "send:s" => \$send_opt,
43            "inbox=s" => \$inbox_opt,
44          "debug" => \$debug,          "debug" => \$debug,
45          "verbose" => \$verbose,          "verbose" => \$verbose,
46          "email=s" => \$email_opt,          "email=s" => \$email_opt,
# Line 120  B<This seems somewhat cludgy, and it wil Line 126  B<This seems somewhat cludgy, and it wil
126                  chomp;                  chomp;
127                  next if (/^#/ || /^\s*$/);                  next if (/^#/ || /^\s*$/);
128                  my ($email, $name) = split(/\s+/,$_, 2);                  my ($email, $name) = split(/\s+/,$_, 2);
129                  $name ||= '';                  $added++ if ($nos->add_member_to_list( email => $email, name => $name, list => $add_opt ));
                 if (! Email::Valid->address($email)) {  
                         print "SKIPPING $name <$email>\n";  
                         next;  
                 }  
                 print "# $name <$email>\n";  
                 my $this_user = $users->find_or_create({  
                         email => $email,  
                         full_name => $name,  
                 }) || die "can't find or create member\n";  
                 my $user_on_list = $user_list->find_or_create({  
                         user_id => $this_user->id,  
                         list_id => $list->id,  
                 }) || die "can't add user to list";  
                 $added++;  
         }  
   
         foreach my $c_name ($loader->tables) {  
                 my $c = $loader->find_class($c_name)|| die "can't find $c_name";  
                 $c->dbi_commit();  
130          }          }
131    
132          print "list ",$list->name," has $added users\n";          print "list ",$list->name," has $added users\n";
# Line 159  add C<--verbose> flag, it will display a Line 146  add C<--verbose> flag, it will display a
146          if ($queue_opt ne '') {          if ($queue_opt ne '') {
147                  # add message to list queue                  # add message to list queue
148    
                 my $this_list = $lists->search(  
                         name => $queue_opt,  
                 )->first || die "can't find list $queue_opt";  
   
149                  my $message_text;                  my $message_text;
150                  while(<>) {                  while(<>) {
151                          $message_text .= $_;                          $message_text .= $_;
152                  }                  }
153    
154                  die "no message" unless ($message_text);                  my $id = $nos->add_message_to_list(
155                            list => $queue_opt,
156                  my $this_message = $messages->find_or_create({                          message => $message_text,
157                          message => $message_text                  );
                 }) || die "can't insert message";  
   
                 $this_message->dbi_commit() || die "can't add message";  
158    
159                  $queue->find_or_create({                  print "added message $id to list $queue_opt\n";
                         message_id => $this_message->id,  
                         list_id => $this_list->id,  
                 }) || die "can't add message ",$this_message->id," to list ",$this_list->id, ": ",$this_list->name;  
   
                 $queue->dbi_commit || die "can't add message to list ",$this_list->name;  
   
                 print "added message ",$this_message->id, " to list ",$this_list->name,"\n";  
160    
161          } else {          } else {
162                  # list messages in queue                          # list messages in queue        
# Line 217  for single list. Line 190  for single list.
190    
191          $nos->send_queued_messages($send_opt);          $nos->send_queued_messages($send_opt);
192    
193    =item --inbox=list_name
194    
195    Feed incomming message back into notice sender.
196    
197    =cut
198    
199    } elsif ($inbox_opt) {
200    
201            warn "inbox option is not implemented";
202    
203  } else  {  } else  {
204          die "see perldoc $0 for help";          die "see perldoc $0 for help";
205  }  }

Legend:
Removed from v.22  
changed lines
  Added in v.29

  ViewVC Help
Powered by ViewVC 1.1.26