The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::SpamcupNG - module to export functions for spamcup program

SYNOPSIS

    use App::SpamcupNG qw(read_config get_browser main_loop config_logger %OPTIONS_MAP);

DESCRIPTION

App-SpamcupNG is a Perl web crawler for finishing Spamcop.net reports automatically. This module implements the functions used by the spamcup program.

See the README.md file on this project for more details.

EXPORTS

read_config

Reads a YAML file, sets the command line options and return the associated accounts.

Expects as parameter a string with the full path to the YAML file and a hash reference of the command line options read (as returned by Getopts::Std getopts function).

The hash reference options will set as defined in the YAML file. Options defined in the YAML have preference of those read on the command line then.

It will also return all data configured in the Accounts section of the YAML file as a hash refence. Check the README.md file for more details about the configuration file.

get_browser

Creates a instance of LWP::UserAgent and returns it.

Expects two string as parameters: one with the name to associated with the user agent and the another as version of it.

config_logger

Configures a Log::Log4perl object, as defined by the verbosity parameter (-V in the command line).

Expected parameters:

  • level

  • path to a log file

If the verbosity is set to DEBUG, all messages will be sent to a log file opened as spamcup.log in append mode.

Otherwise, all messages will be sent to STDOUT.

Verbosity modes are:

  • DEBUG

  • INFO

  • WARN

  • ERROR

  • FATAL

Depending on the verbosity level, more or less information you be provided. See Log::Log4perl for more details about the levels.

main_loop

Processes all the pending SPAM reports in a loop until finished.

Expects as parameter (in this sequence):

  • a LWP::UserAgent instance

  • A hash reference with the following key/values:

    • ident => The identity to Spamcop

    • pass => The password to Spamcop

    • delay => time in seconds to wait for next iteration with Spamcop website

    • verbosity => defines what level of information should be provided. Uses the same values as defined by Log::Log4perl.

      As confusing as it seems, current implementation may accept debug messages and disable other messages.

    • check_only => true (1) or false (0) to only check for unreported SPAM, but not reporting them

Returns true if everything went right, or die if a fatal error happened.

SEE ALSO

AUTHOR

Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 of Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>

This file is part of App-SpamcupNG distribution.

App-SpamcupNG 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.

App-SpamcupNG 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 App-SpamcupNG. If not, see <http://www.gnu.org/licenses/>.