]> ruin.nu Git - NDIRC.git/blobdiff - ndawn.pl
Update to new database structure
[NDIRC.git] / ndawn.pl
index ffb7e5851a9ec17c1c396af7722d7887b6290a49..0de8351ac4e80a5ab9a6dd7293f8657582724142 100644 (file)
--- a/ndawn.pl
+++ b/ndawn.pl
@@ -1,5 +1,5 @@
 #**************************************************************************
-#   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  *
@@ -55,25 +55,46 @@ my $TICK = $DBH->selectrow_array('SELECT tick()');
 
 my $disp = new NDIRC::Dispatcher;
 
-$disp->load('Basic','PA');
+$disp->load(qw/Basic SMS Channel Def Intel Members PA Quotes Scans Usermgm/);
 
-$disp->add_channel('#testarlite', ['pub','help']);
-$disp->add_channel('#testarmer', ['pub','help']);
+$ND::scanchan = '#testarmer';
+$ND::defchan = '#testarlite';
+$ND::memchan = '#testarmer';
+$disp->add_channel($ND::defchan, ['pub','help','channel','def']);
+$disp->add_channel($ND::scanchan, ['pub','help','channel','scan','member']);
+$disp->add_channel('pm', ['pub','help','pm']);
 
 sub event_pubmsg {
        my ($server, $msg, $nick, $address, $channel) = @_;
 
-       if (parseCommand($msg,$server,$nick,$address,$channel,$disp,DB())){
-               #Command parsed and run successfully
-       }
+       eval {
+               if ($msg =~ /^(\S+): (.+)$/ && $disp->has_command('anon',$channel)){
+                       my $_ = $1;
+                       my $text = $2;
+                       my $channel = $server->channel_find($channel);
+                       my $nick = $channel->nick_find($1);
+                       unless ($nick || /(Constructing|Researching)/){
+                               print ".anon $_ $text";
+                               $msg = ".anon $_ $text";
+                       }
+
+               }
+               if (parseCommand($msg,$server,$nick,$address,$channel,$disp,DB())){
+                       #Command parsed and run successfully
+               }
+       };
+       print $@ if $@;
 }
 
 sub event_privmsg {
        my ($server, $msg, $nick, $address) = @_;
 
-       if (parseCommand($msg,$server,$nick,$address,'pm',$disp,DB())){
-               #Command parsed and run successfully
-       }
+       eval {
+               if (parseCommand($msg,$server,$nick,$address,'pm',$disp,DB())){
+                       #Command parsed and run successfully
+               }
+       };
+       print $@ if $@;
 }
 
 sub refresh {