]> ruin.nu Git - NDIRC.git/blobdiff - ndawn.pl
Split long lines, using the algorithm from irssi splitlong.pl
[NDIRC.git] / ndawn.pl
old mode 100644 (file)
new mode 100755 (executable)
index ffb7e58..a14ee36
--- 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;
-
-$SIG{USR1} = sub{
-       print "USR1";
-       $ND::refresh = 1;
-};
-
+use feature ':5.10';
+use POE qw(Component::IRC::Qnet::State);
 
-use again 'ND::DB';
-use again 'ND::Include';
-use again 'NDIRC::Dispatcher';
-use again 'NDIRC::Context';
-use again 'NDIRC::Command';
-use again 'NDIRC::Misc';
+eval "require NDIRC::$ARGV[0]";
 
-my $DBH = DB();
-my $TICK = $DBH->selectrow_array('SELECT tick()');
+die $@ if $@;
 
-my $disp = new NDIRC::Dispatcher;
+# 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! $!";
 
-$disp->load('Basic','PA');
+$irc->service_bots(QBOT => 'P@cservice.netgamers.org');
 
-$disp->add_channel('#testarlite', ['pub','help']);
-$disp->add_channel('#testarmer', ['pub','help']);
-
-sub event_pubmsg {
-       my ($server, $msg, $nick, $address, $channel) = @_;
-
-       if (parseCommand($msg,$server,$nick,$address,$channel,$disp,DB())){
-               #Command parsed and run successfully
-       }
-}
-
-sub event_privmsg {
-       my ($server, $msg, $nick, $address) = @_;
-
-       if (parseCommand($msg,$server,$nick,$address,'pm',$disp,DB())){
-               #Command parsed and run successfully
-       }
-}
-
-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');
+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();