]> ruin.nu Git - NDIRC.git/blobdiff - ndawn.pl
A bit more for the common states
[NDIRC.git] / ndawn.pl
old mode 100644 (file)
new mode 100755 (executable)
index 76fca28..f2eafaa
--- a/ndawn.pl
+++ b/ndawn.pl
@@ -1,5 +1,7 @@
+#!/usr/bin/perl -w
+
 #**************************************************************************
-#   Copyright (C) 2008 by Michael Andreen <harvATruinDOTnu>               *
+#   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  *
 #   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 vars qw($VERSION %IRSSI);
-
-use Irssi;
-use Irssi::Irc;
-
-$VERSION = "0.1";
-%IRSSI = (
-    authors => "harv",
-    contact => "harv\@ruin.nu",
-    name    => "NewDawn testbot script",
-    description => "Testbot used for implementing commands for nd bots",
-    license => "GPL-2 or (at your option) any later version",
-    url     => "",
-    changed => "",
-);
-
-$ND::refresh = 0;
+use feature ':5.10';
+use POE qw(Component::IRC::Qnet::State);
 
-$SIG{USR1} = sub{
-       print "USR1";
-       $ND::refresh = 1;
-};
 
+use NDIRC::CommonStates;
+use NDIRC::Delling;
 
-use again 'ND::DB';
-use again 'ND::Include';
-use again 'NDIRC::Dispatcher';
-use again 'NDIRC::Context';
-use again 'NDIRC::Command';
-use again 'NDIRC::Misc';
+my $nickname = 'ndbot';
+my $ircname = 'ND test bot';
+my $server = 'irc.netgamers.org';
 
-my $DBH = DB();
-my $TICK = $DBH->selectrow_array('SELECT tick()');
+# We create a new PoCo-IRC object
+my $irc = POE::Component::IRC::Qnet::State->spawn(
+       nick => $nickname,
+       ircname => $ircname,
+       server => $server,
+       servers => [$server, 'underworld.no.eu.netgamers.org', ]
+) or die "Oh noooo! $!";
 
-my $disp = new NDIRC::Dispatcher;
-
-$disp->load('Basic','PA','Channel','Scans');
+$irc->service_bots(QBOT => 'P@cservice.netgamers.org');
 
 $ND::scanchan = '#testarmer';
-$disp->add_channel('#testarlite', ['pub','help','channel']);
-$disp->add_channel('#testarmer', ['pub','help','channel','scan']);
-$disp->add_channel('pm', ['pub','help','pm']);
-
-sub event_pubmsg {
-       my ($server, $msg, $nick, $address, $channel) = @_;
-
-       eval {
-               if (parseCommand($msg,$server,$nick,$address,$channel,$disp,DB())){
-                       #Command parsed and run successfully
-               }
-       };
-       print $@ if $@;
-}
-
-sub event_privmsg {
-       my ($server, $msg, $nick, $address) = @_;
-
-       eval {
-               if (parseCommand($msg,$server,$nick,$address,'pm',$disp,DB())){
-                       #Command parsed and run successfully
-               }
-       };
-       print $@ if $@;
-}
-
-sub refresh {
-       print "SiG" if $ND::refresh;
-       $ND::refresh = 0;
-}
-
-Irssi::timeout_add(60*1000, 'refresh', undef);
-Irssi::timeout_add(1000, sub{refresh if $ND::refresh}, undef);
-Irssi::signal_add('message public','event_pubmsg');
-Irssi::signal_add('message private','event_privmsg');
-
+$ND::defchan = '#testarlite';
+$ND::memchan = '#testarmer';
+
+POE::Session->create(
+       package_states => [
+               'NDIRC::CommonStates' => [ qw(_default _start irc_001 sig_DIE sig_usr1 sig_usr2
+                       signal_handler irc_disconnected irc_invite) ],
+               'NDIRC::Delling' => [ qw(irc_public irc_msg refresh irc_join) ],
+       ],
+       heap => { irc => $irc},
+);
 
+$poe_kernel->run();