Re: mailer "module" for 'eselect news' (Re: [gentoo-user] from Firefox52: NO pure ALSA?,

2016-12-28 Thread lee
Neil Bothwick  writes:

> On Wed, 28 Dec 2016 17:20:50 +0100, lee wrote:
>
>> > #!/bin/sh
>> >
>> > if [ $( eselect news count new ) != "0" ]; then
>> >eselect news list | mail y...@wherever.you.are
>> >fi  
>> 
>> Thanks!  To actually read the news as email, I wrote this:
>> 
>> #!/usr/bin/perl
> [massive snip]
>
> What does this actually do? Does it separate each news item into a
> separate mail, which sounds a neat idea. If you just want all the news
> news items, you could replace "list" with "read new" in my
> script^H^H^H^H^^Hhack.

You can set it up either way, i. e. all in one email, or each item in
one, or several items in several mails, by setting $msglen.  I didn't
know there is 'read new' ...



Re: mailer "module" for 'eselect news' (Re: [gentoo-user] from Firefox52: NO pure ALSA?, WAS: Firefox 49.0 & Youtube... Audio: No)

2016-12-28 Thread Neil Bothwick
On Wed, 28 Dec 2016 17:20:50 +0100, lee wrote:

> > #!/bin/sh
> >
> > if [ $( eselect news count new ) != "0" ]; then
> >eselect news list | mail y...@wherever.you.are
> >fi  
> 
> Thanks!  To actually read the news as email, I wrote this:
> 
> #!/usr/bin/perl
[massive snip]

What does this actually do? Does it separate each news item into a
separate mail, which sounds a neat idea. If you just want all the news
news items, you could replace "list" with "read new" in my
script^H^H^H^H^^Hhack.


-- 
Neil Bothwick

 ... We are Dyslexics of Borg. Your ass will be laminated.


pgpXBwLN8pnIA.pgp
Description: OpenPGP digital signature


mailer "module" for 'eselect news' (Re: [gentoo-user] from Firefox52: NO pure ALSA?, WAS: Firefox 49.0 & Youtube... Audio: No)

2016-12-28 Thread lee
Neil Bothwick  writes:

> On Tue, 27 Dec 2016 20:21:19 +0100, lee wrote:
>
>> >  Even more reasonable:
>> >
>> >  eselect news read new
>> >
>> > will only come up with the latest as yet unread news, rather than a
>> > long list which could have accumulated over the years.  
>> 
>> It seems to be clearing out the list automatically.
>> 
>> [1] says the mailer module of eselect was removed.  Is there a better
>> way to read them than with eselect?
>
> Put this script in /etc/portage/postsync.d and make it executable
>
> #!/bin/sh
>
> if [ $( eselect news count new ) != "0" ]; then
>eselect news list | mail y...@wherever.you.are
>fi

Thanks!  To actually read the news as email, I wrote this:


#!/usr/bin/perl
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .
#
#
# You may need to emerge dev-perl/Email-MIME and dev-perl/Email-Sender
# for this to work.
#

use strict;
use warnings;
use Email::MIME;
use Email::Sender::Simple qw(sendmail);


 configure this 

my @rcpt = ('l...@yagibdah.de');
my $from = 'r...@yagibdah.de';
my $subj = 'eselect news';
#
# you can set this to 0 to get an email for every news item
#
my $msglen = 65536;

#
# set to 1 to get only items listed as new
#
my $only_new = 1;

 / configure this ###


my @list = qx/eselect news list/;
my @numbers = $only_new ? map(m/\A\s*\[(\d+)\]\s*N\s*\d/, @list) : map(m/\A\s*\[(\d+)\]/, @list);
my $content = join('', @list) . "\n" . ('#' x 70) . "\n\n";
undef @list;

foreach (@numbers) {
  my $do = "eselect news read $_";
  $content .= qx/$do/;
  $content .= "\n" . ('#' x 70) . "\n\n";

  if (length($content) > $msglen) {
my $message = Email::MIME->create(
  header_str => [
		 From=> $from,
		 To  => @rcpt,
		 Subject => $subj
		],
  attributes => {
		 encoding => 'quoted-printable',
		 charset  => 'UTF-8'
		},
  body_str => $content
 );
sendmail($message);

$content = '';
  }
}

if (length($content)) {
  my $message = Email::MIME->create(
header_str => [
		   From=> $from,
		   To  => @rcpt,
		   Subject => $subj
		  ],
attributes => {
		   encoding => 'quoted-printable',
		   charset  => 'UTF-8'
		  },
body_str => $content
   );
  sendmail($message);
}


exit 0;