Bot-Pastebot

 view release on metacpan or  search on metacpan

pastebot  view on Meta::CPAN

our $VERSION = '0.543';

use File::Basename;
use Perl::Tidy;

use POE;
use Bot::Pastebot;
use Bot::Pastebot::Conf;
use Bot::Pastebot::Data;
use Bot::Pastebot::Client::Irc;
use Bot::Pastebot::Server::Http;
use Bot::Pastebot::Administrivia qw/uses_pidfile get_pid write_pidfile/;

my %conf = (
  Bot::Pastebot::Data->get_conf(),
  Bot::Pastebot::Client::Irc->get_conf(),
  Bot::Pastebot::Server::Http->get_conf(),
  Bot::Pastebot::Administrivia->get_conf(),
);

# Command line options.

my $conf_file = Bot::Pastebot::Conf->get_conf_file();
Bot::Pastebot::Conf->load($conf_file, \%conf);

if (uses_pidfile() && (my $pid = get_pid()) ) {
  die(
    "pastebot seems to be running as PID $pid.\n",
    "Please check if this is the case.\n",
  );
} elsif( uses_pidfile() ) {
  write_pidfile();
}

Bot::Pastebot::Data->initialize();
Bot::Pastebot::Client::Irc->initialize();
Bot::Pastebot::Server::Http->initialize();

POE::Kernel->run();
exit 0;

sub HELP_MESSAGE {
  my $output = shift;
  print $output "usage:\n";
  print $output "  $0 -f file.conf (configure and run a pastebot)\n";
  print $output "\n";
  print $output "  You can read pastebot's documentation with the\n";
  print $output "  perldoc command.  Run:  perldoc pastebot\n";
  exit;
}

sub VERSION_MESSAGE {
  my $output = shift;
  print $output "$0 version $VERSION\n";
}

__END__

=head1 NAME

pastebot - the original clipboard to chat gateway

=head1 SYNOPSIS

pastebot -f configfile

=head1 DESCRIPTION

Pastebot is an IRC bot and a web server in one program.  Users submit
short pieces of text to the web server, and the IRC bot announces them
in IRC.

A single pastebot instance can provide one or more web servers, each
accepting connections on a different virtual host and/or port.

Likewise, a single pastebot may connect to zero or more IRC networks
and announce pastes on zero or more channels on each.  The pastebot
merely acts as a web service in zero-bot mode.

=head1 CONFIGURATION SYNTAX

Nearly all of pastebot's options are set in a configuration file.  The
general syntax for this file follows these rules:

Sections are defined by text that begins in the first column.  Section
parameters are indented and consist of a parameter name and its value
separated by whitespace.  This example defines a web_server section
named "poenet" that listens on port 8888.

  web_server
    name  poenet
    port  8888

Each section defines a component type within the pastebot.  Each
section requires a unique name since there may be more than one
instance of a component.  The names permit the program to reference
specific components without confusion.

Some parameters may contain multiple values, though.  Each value is
defined on a separate configuration line using the same parameter
name.  For example, it's useful to configure multiple IRC servers for
a bot to choose from.  If one server is unavailable, it can try
another.  Here's how that's done:

  irc
    name efnet
    server irc.carrier1.net.uk  6667
    server irc.daxnet.no        6667

Configuration files may contain comments, which are text after a hash
mark ("#").  Comments and blank lines are ignored.

  # Configure the paste database.
  pastes
    expire 86400

That's all.

=head1 CONFIGURING PASTEBOT

Pastebot configuration is broken down into three section types:



( run in 0.625 second using v1.01-cache-2.11-cpan-84e82930d8c )