package Mail::ListDetector::Detector::CommuniGate;

use strict;
use warnings;

use vars qw($VERSION);
use Email::Abstract;
$VERSION = '0.01';

use base qw(Mail::ListDetector::Detector::Base);
use Mail::ListDetector::List;
use Carp;

sub DEBUG { 0 }

sub match {
	my $self = shift;
	my $message = shift;
	print "Got message $message\n" if DEBUG;
	carp ("Mail::ListDetector::Detector::CommuniGate - no message supplied") unless defined($message);

	my $x_listserver = Email::Abstract->get_header($message, 'X-Listserver');
	if (defined($x_listserver) && ($x_listserver =~ m/CommuniGate List/)) {
		chomp $x_listserver;

		my $sender = Email::Abstract->get_header($message, 'Sender');
		return undef unless defined($sender);
		$sender =~ m/([^\s]+@[^\s]+)\s+\((.*)\)/ or return undef;
		my $posting_address = $1;
		my $listname = $2;

		my $list = new Mail::ListDetector::List;


		return $list;
	} else {
		return undef;




=head1 NAME

Mail::ListDetector::Detector::CommuniGate - CommuniGate message detector


  use Mail::ListDetector::Detector::CommuniGate;


An implementation of a mailing list detector, for CommuniGate mailing lists,
CommuniGate is a legacy MacOS messaging application, see for details about CommuniGate.

=head1 METHODS

=head2 new()

Inherited from Mail::ListDetector::Detector::Base.

=head2 match()

Accepts a Mail::Internet object and returns either a
Mail::ListDetector::List object if it is a post to a CommuniGate
mailing list, or C<undef>.

=head1 BUGS

No known bugs.

=head1 AUTHOR

Matthew Walker -,
Michael Stevens -,
Peter Oliver -
Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.