NAME
News::Article::Response - create responses to News::Articles
SYNOPSIS
use News::Article::Response;
my $newart = News::Article->response($oldart,
{ 'From' => 'Random User <random@user.org.invalid>' },
'prefix' => 'random.', 'colwrap' => 80, 'nodate' => 1 );
use News::Article::Response qw( quotewrap );
my @wrappedtext = quotewrap( 80, '> ', 'overflow', @text );
DESCRIPTION
News::Article::Response is a set of additional functions for News::Article to create responses to previous articles.
USAGE
Functions
- response ( ARTICLE, HEADERS, ARGUMENTS )
-
Creates a new article that's in response to
ARTICLE
- that is, with headers based on the originalARTICLE
. Base headers that are created should be Message-ID, Date, Newsgroups, References, and Subject; more headers will be added as given in the hash referenceHEADERS
. The body of the message is a quoted version of the original message with the signature trimmed off.ARGUMENTS
, a hash, allows for user-modifed behavior. Arguments that we listen to:prefix Message-ID prefix (see News::Article) domain Message-ID domain (see News::Article) nomessageid Don't actually add a Message-ID: header time Time to base Date: off (defaults to local time) nodate Don't actually add a Date: header ignore_followups Ignore the Followup-To: header when deciding what groups to respond to. Especially important if the original line was 'poster', as we return with 'undef' in that case (we should be sending an email) newsgroups Newsgroups to respond to, ignoring both the old Newsgroups: and Followup-To: headers. keepsig Keep the signature for quoting. quotechar The quote method; defaults to '> ', for use with wrap(). colwrap Columns to wrap at, for use with wrap(). wraptype Wrapping type, for use with wrap(). respstring A code reference that takes as input the old article, and generates a string of the sort "Tim Skirvin writes:" for the start of the body. The default gets the information out of From: or Reply-To:, or failing that uses uses '(unknown)'. Doesn't get added if there's no quoted material.
Returns 'undef' on failure (not enough arguments, followups were set to poster so there shouldn't be an article anyway), otherwise returns a News::Article object.
- quotewrap ( COLUMNS, QUOTECHAR, WRAPTYPE, TEXT )
-
Adds
QUOTECHAR
to the start of each line of text fromTEXT
, and then wraps the text atCOLUMNS
columns where necessary. This differs from Text::Wrap in that lines that don't need to be wrapped won't be; that is, we keep as much of the original formatting as possible.If
COLUMNS
is less than 0, then don't actually do the wrapping.WRAPTYPE
is currently ignored. It probably won't be forever. Offer it the same values as in Text::Wrap.This function can be imported by other programs, but is not by default (@EXPORT_OK).
REQUIREMENTS
News::Article, Exporter, and of course Perl (probably a fairly modern version at that).
SEE ALSO
News::Article, News::Web
NOTES
This was originally written to work with my News::Web project (which I plan to release), and much of the code was from old News::Verimod (which I may not release). It's now part of my newslib project (which *is* released: http://www.killfile.org/~tskirvin/software/newslib/). It should be fairly general-purpose, but we'll see.
TODO
It would be nice if quotewrap() were to reformat paragraphs into something reasonable when they're quoted; we'll see if it's something worth doing.
Get rid of the dependency on Text::Wrap, since we're not actually using it except in an internal function that doesn't get called.
AUTHOR
Tim Skirvin <tskirvin@killfile.org>
COPYRIGHT
Copyright 2003 by Tim Skirvin <tskirvin@killfile.org>. This code may be distributed under the same terms as Perl itself.