#!/usr/bin/perl -w

#**************************************************************************
#   Copyright (C) 2009 by Michael Andreen <harvATruinDOTnu>               *
#                                                                         *
#   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 2 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, write to the                         *
#   Free Software Foundation, Inc.,                                       *
#   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
#**************************************************************************

use strict;
use warnings;
use feature ':5.10';

#use Devel::Leak::Object qw{ GLOBAL_bless };
use POE qw(Component::IRC::Qnet::State);

use Moose;
use MooseX::Declare;
use MooseX::Declare::StackItem;
use Parse::Method::Signatures::Sig;
use MooseX::Types::TypeDecorator;
use MooseX::Meta::TypeConstraint::ForceCoercion;

use NDIRC::Bot;

eval "require NDIRC::$ARGV[0]";

die $@ if $@;

# We create a new PoCo-IRC object
my $irc = POE::Component::IRC::Qnet::State->spawn(
	nick => $ARGV[0],
	ircname => 'ND bot',
) or die "Oh noooo! $!";

$irc->service_bots(QBOT => 'P@cservice.netgamers.org');

my $bot = eval "new NDIRC::$ARGV[0]";

POE::Session->create(
	object_states => [
		$bot => [ qw(_default _start irc_001 sig_DIE sig_usr1 sig_usr2
			signal_handler irc_disconnected irc_invite auth
			irc_public irc_msg refresh irc_join) ],
	],
	heap => { irc => $irc },
);

$poe_kernel->run();
