[NeoStats-Devel] [Commits] r2685 - in trunk: modules/perltest src

[email protected]
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Fish
Date: Mon Aug  1 20:39:14 2005
New Revision: 2685

Modified:
   trunk/modules/perltest/test.pl
   trunk/src/NeoStats.pm
   trunk/src/neostats.pm.h
   trunk/src/perl.c
Log:
more perl module stuff

Modified: trunk/modules/perltest/test.pl
==============================================================================
--- trunk/modules/perltest/test.pl	(original)
+++ trunk/modules/perltest/test.pl	Mon Aug  1 20:39:14 2005
@@ -8,6 +8,8 @@
 # First thing that you must ensure happens (ie, first command) is to register this script
 # Using the following command:
 
+my $bot;
+
 NeoStats::register( "Test", "1.0", "Test Script 1 description", "setupbot", "shutdownbot");
 
 # Events make up the core communications of NeoStats, here you register the events your 
@@ -71,267 +73,267 @@
 
 sub event_moduleload {
 	my ($param1) = @_;
-	NeoStats::print("New Module Loaded: $param1");
+	NeoStats::debug("New Module Loaded: $param1");
 }
 
 sub event_moduleunload {
 	my ($param1) = @_;
-	NeoStats::print("Module Unloaded: $param1");
+	NeoStats::debug("Module Unloaded: $param1");
 }
 
 sub event_server {
 	my ($test) = @_;
-	NeoStats::print ("New Server $test");
+	NeoStats::debug ("New Server $test");
 	my $server = NeoStats::FindServer($test);
-	NeoStats::print ("Server Uplink $test->{uplink}");
+	NeoStats::debug ("Server Uplink $test->{uplink}");
 }
 
 sub event_squit {
 	my ($server, $msg) = @_;
-	NeoStats::print ("Server $server Squit: $msg");
+	NeoStats::debug ("Server $server Squit: $msg");
 }
 
 sub event_ping {
 	my ($source) = @_;
-	NeoStats::print ("Ping $source");
+	NeoStats::debug ("Ping $source");
 }
 
 sub event_pong {
 	my ($source) = @_;
-	NeoStats::print ("Pong $source");
+	NeoStats::debug ("Pong $source");
 }
 
 sub event_signon {
 	my ($source) = @_;
-	NeoStats::print ("Signon $source");
+	NeoStats::debug ("Signon $source");
 	my $user = NeoStats::FindUser($source);
-	NeoStats::print ("Host: $user->{hostname}");
-	NeoStats::print ("Server $user->{server}");
+	NeoStats::debug ("Host: $user->{hostname}");
+	NeoStats::debug ("Server $user->{server}");
 }
 
 sub event_quit {
 	my ($source, $msg) = @_;
-	NeoStats::print ("Quit $source: $msg");
+	NeoStats::debug ("Quit $source: $msg");
 }
 
 sub event_nickip {
 	my ($source) = @_;
-	NeoStats::print ("NickIP $source");
+	NeoStats::debug ("NickIP $source");
 }
 
 sub event_kill {
 	my ($source, $target, $msg) = @_;
-	NeoStats::print ("KILL $target by $source: $msg");
+	NeoStats::debug ("KILL $target by $source: $msg");
 }
 
 sub event_globalkill {
 	my ($source, $target, $msg) = @_;
-	NeoStats::print ("GLOBALKILL $target by $source: $msg");
+	NeoStats::debug ("GLOBALKILL $target by $source: $msg");
 }
 
 sub event_localkill {
 	my ($source, $target, $msg) = @_;
-	NeoStats::print ("LOCALKILL $target by $source: $msg");
+	NeoStats::debug ("LOCALKILL $target by $source: $msg");
 }
 
 sub event_serverkill {
 	my ($source, $target, $msg) = @_;
-	NeoStats::print ("SEVERKILL $target by $source: $msg");
+	NeoStats::debug ("SEVERKILL $target by $source: $msg");
 }
 
 sub event_botkill {
 	my ($target, $msg) = @_;
-	NeoStats::print ("BOTKILL $target: $msg");
+	NeoStats::debug ("BOTKILL $target: $msg");
 }
 
 sub event_nick {
 	my ($source, $target) = @_;
-	NeoStats::print ("NICKChange $source: $target");
+	NeoStats::debug ("NICKChange $source: $target");
 }
 
 sub event_away {
 	my ($source) = @_;
-	NeoStats::print ("AwayChange $source");
+	NeoStats::debug ("AwayChange $source");
 }
 
 sub event_umode {
 	my ($source, $mode) = @_;
-	NeoStats::print ("UMODE $source, $mode");
+	NeoStats::debug ("UMODE $source, $mode");
 }
 
 sub event_smode {
 	my ($source, $mode) = @_;
-	NeoStats::print ("SMODE $source, $mode");
+	NeoStats::debug ("SMODE $source, $mode");
 }
 
 sub event_newchan {
 	my ($channel) = @_;
-	NeoStats::print ("NewChan $channel");
+	NeoStats::debug ("NewChan $channel");
 }
 
 sub event_delchan {
 	my ($channel) = @_;
-	NeoStats::print ("DelChan $channel");
+	NeoStats::debug ("DelChan $channel");
 }
 
 sub event_join {
 	my ($channel, $source) = @_;
-	NeoStats::print ("Join $channel: $source");
+	NeoStats::debug ("Join $channel: $source");
 	my $chan = NeoStats::FindChan($channel);
-	NeoStats::print ("Channel users $chan->{users}");
+	NeoStats::debug ("Channel users $chan->{users}");
 }
 
 sub event_part {
 	my ($channel, $source, $msg) = @_;
-	NeoStats::print ("Part $channel: $source: $msg");
+	NeoStats::debug ("Part $channel: $source: $msg");
 }
 
 sub event_partbot {
 	my ($channel, $source, $msg) = @_;
-	NeoStats::print ("Partbot $channel: $source: $msg");
+	NeoStats::debug ("Partbot $channel: $source: $msg");
 }
 
 sub event_emptychan {
 	my ($channel, $source, $bot, $msg) = @_;
-	NeoStats::print ("Empty $channel $source $bot: $msg");
+	NeoStats::debug ("Empty $channel $source $bot: $msg");
 }
 
 sub event_kick {
 	my ($channel, $source, $target, $msg) = @_;
-	NeoStats::print ("Kick $channel $source $target: $msg");
+	NeoStats::debug ("Kick $channel $source $target: $msg");
 }
 
 sub event_kickbot {
 	my ($channel, $source, $target, $msg) = @_;
-	NeoStats::print ("Kickbot $channel $source $target: $msg");
+	NeoStats::debug ("Kickbot $channel $source $target: $msg");
 }
 
 sub event_topic {
 	my ($channel, $source) = @_;
-	NeoStats::print ("Topic $channel $source");
+	NeoStats::debug ("Topic $channel $source");
 }
 
 sub event_cmode {
-	NeoStats::print ("ToDO");
+	NeoStats::debug ("ToDO");
 }
 
 sub event_private {
 	my ($source, $target, $msg) = @_;
-	NeoStats::print ("Privmsg $source $target: $msg");
+	NeoStats::debug ("Privmsg $source $target: $msg");
 }
 
 sub event_notice {
 	my ($source, $target, $msg) = @_;
-	NeoStats::print ("NOTICE $source $target: $msg");
+	NeoStats::debug ("NOTICE $source $target: $msg");
 }
 
 sub event_cprivate {
 	my ($source, $target, $msg) = @_;
-	NeoStats::print ("CPRIVATE $source $target: $msg");
+	NeoStats::debug ("CPRIVATE $source $target: $msg");
 }
 
 sub event_cnotice {
 	my ($source, $target, $msg) = @_;
-	NeoStats::print ("CNOTICE $source $target: $msg");
+	NeoStats::debug ("CNOTICE $source $target: $msg");
 }
 
 sub event_globops {
 	my ($source, $msg) = @_;
-	NeoStats::print ("GLOBOPS $source $msg");
+	NeoStats::debug ("GLOBOPS $source $msg");
 }
 
 sub event_chatops {
 	my ($source, $msg) = @_;
-	NeoStats::print ("CHATOPS $source: $msg");
+	NeoStats::debug ("CHATOPS $source: $msg");
 }
 
 sub event_wallops {
 	my ($source, $msg) = @_;
-	NeoStats::print ("WALLOPS $source: $msg");
+	NeoStats::debug ("WALLOPS $source: $msg");
 }
 
 sub event_ctcpversionrpl {
 	my ($source, $msg) = @_;
-	NeoStats::print ("CTCPVERSIONRPL $source: $msg");
+	NeoStats::debug ("CTCPVERSIONRPL $source: $msg");
 }
 
 sub event_ctcpversionreq {
 	my ($source) = @_;
-	NeoStats::print ("CTCPVERSIONREQ $source");
+	NeoStats::debug ("CTCPVERSIONREQ $source");
 }
 
 sub event_ctcpfingerrpl {
 	my ($source, $msg) = @_;
-	NeoStats::print ("CTCPFINGERRPL $source: $msg");
+	NeoStats::debug ("CTCPFINGERRPL $source: $msg");
 }
 
 sub event_ctcpfingerreq {
 	my ($source) = @_;
-	NeoStats::print ("CTCPFINGERREQ $source");
+	NeoStats::debug ("CTCPFINGERREQ $source");
 }
 
 sub event_ctcpactionreq {
 	my ($source) = @_;
-	NeoStats::print ("CTCPACTIONREQ $source");
+	NeoStats::debug ("CTCPACTIONREQ $source");
 }
 
 sub event_ctcptimerpl {
 	my ($source, $msg) = @_;
-	NeoStats::print ("CTCPTIMERPL $source: $msg");
+	NeoStats::debug ("CTCPTIMERPL $source: $msg");
 }
 
 sub event_ctcptimereq {
 	my ($source) = @_;
-	NeoStats::print ("CTCPTIMEREQ $source");
+	NeoStats::debug ("CTCPTIMEREQ $source");
 }
 
 sub event_ctcppingrpl {
 	my ($source, $msg) = @_;
-	NeoStats::print ("CTCPPINGRPL $source: $msg");
+	NeoStats::debug ("CTCPPINGRPL $source: $msg");
 }
 
 sub event_ctcppingreq {
 	my ($source) = @_;
-	NeoStats::print ("CTCPPINGREQ $source");
+	NeoStats::debug ("CTCPPINGREQ $source");
 }
 
 sub event_dccsend {
 	my ($source, $msg) = @_;
-	NeoStats::print ("DCCSEND $source: $msg");
+	NeoStats::debug ("DCCSEND $source: $msg");
 }
 
 sub event_dccchat {
 	my ($source, $msg) = @_;
-	NeoStats::print ("DCCCHAT $source: $msg");
+	NeoStats::debug ("DCCCHAT $source: $msg");
 }
 
 sub event_dccmsg {
 	my ($source, $msg) = @_;
-	NeoStats::print ("DCCMSG $source: $msg");
+	NeoStats::debug ("DCCMSG $source: $msg");
 }
 
 sub event_addban {
-	NeoStats::print ("AddBan");
+	NeoStats::debug ("AddBan");
 }
 
 sub event_delban {
-	NeoStats::print ("DelBan");
+	NeoStats::debug ("DelBan");
 }
 
 
 
 sub setupbot {
 	my $botinfo;
-	NeoStats::print("Setup");
+	NeoStats::debug("Setup");
 	$botinfo->{nick} = "Fishy";
 	$botinfo->{altnick} = "Fishy2";
 	$botinfo->{ident} = "fish";
 	$botinfo->{host} = "Host.com";
 	$botinfo->{gecos} = "My Gecos";
-	my $bot = NeoStats::AddBot($botinfo, NeoStats::BOT_FLAG_SERVICEBOT);
+	$bot = NeoStats::AddBot($botinfo, NeoStats::BOT_FLAG_SERVICEBOT);
 	$botinfo->{nick} = "fishy2";
 	NeoStats::AddBot($botinfo, NeoStats::BOT_FLAG_SERVICEBOT);
-	NeoStats::print("Added Second Bot $botinfo->{nick}");
+	NeoStats::debug("Added Second Bot $botinfo->{nick}");
 	NeoStats::DelBot($botinfo->{nick});
 
 
@@ -351,14 +353,18 @@
 		flags => '0',
 	};
 	NeoStats::AddCmd($bot, $cmd, 'cmd_cb_test');
-	NeoStats::print(NeoStats::DelCmd($bot, $cmd->{cmd}));
+	NeoStats::debug(NeoStats::DelCmd($bot, $cmd->{cmd}));
+	NeoStats::ChanAlert($bot, "Loaded up and ready to rock and role");
 }
 
 sub cmd_cb_test {
-	NeoStats::print("Got Test Command");
+	my ($cmd, $who, $params) = @_;
+	NeoStats::debug("Got $cmd Command from $who: $params ");
+	NeoStats::PrefMsg($bot, $who, "You Sent me this: $params");
+	return NeoStats::NS_SUCCESS;
 }
 
 sub shutdownbot {
-	NeoStats::Print("Shutdown");
+	NeoStats::debug("Shutdown");
 }
 

Modified: trunk/src/NeoStats.pm
==============================================================================
--- trunk/src/NeoStats.pm	(original)
+++ trunk/src/NeoStats.pm	Mon Aug  1 20:39:14 2005
@@ -44,7 +44,7 @@
 
   sub register {
     if (@_ != 5) {
-      NeoStats::print("Invalid Number of arguments to register");
+      NeoStats::debug("Invalid Number of arguments to register");
       return NeoStats::NS_FAILURE;
     }
     my ($package) = caller;
@@ -73,7 +73,7 @@
 
   sub hook_event {
     if (@_ < 2) {
-      NeoStats::print("Invalid Number of arguments to hook_event");
+      NeoStats::debug("Invalid Number of arguments to hook_event");
       return NeoStats::NS_FAILURE;
     }
 
@@ -105,7 +105,7 @@
   }
   
   sub unhook_event {
-    NeoStats::print("todo");
+    NeoStats::debug("todo");
     return NeoStats::NS_FAILURE;
   }
 
@@ -113,7 +113,7 @@
 # AddBot(botinfo, botflag)
   sub AddBot {
     if (@_ < 2) {
-      NeoStats::print("Invalid Number of arguments to AddBot");
+      NeoStats::debug("Invalid Number of arguments to AddBot");
       return NeoStats::NS_FAILURE;
     }
 
@@ -127,23 +127,23 @@
       return NeoStats::NS_FAILURE;
     }
     if ((!exists( $botinfo->{nick} )) || (!defined( $botinfo->{nick} ))) {
-      NeoStats::print("Botinfo->{nick} not defined");
+      NeoStats::debug("Botinfo->{nick} not defined");
       return NeoStats::NS_FAILURE;
     }    
     if ((!exists( $botinfo->{altnick} )) || (!defined( $botinfo->{altnick} ))) {
-      NeoStats::print("Botinfo->{altnick} not defined");
+      NeoStats::debug("Botinfo->{altnick} not defined");
       return NeoStats::NS_FAILURE;
     }    
     if ((!exists( $botinfo->{ident} )) || (!defined( $botinfo->{ident} ))) {
-      NeoStats::print("Botinfo->{ident} not defined");
+      NeoStats::debug("Botinfo->{ident} not defined");
       return NeoStats::NS_FAILURE;
     }    
     if ((!exists( $botinfo->{host} )) || (!defined( $botinfo->{host} ))) {
-      NeoStats::print("Botinfo->{host} not defined");
+      NeoStats::debug("Botinfo->{host} not defined");
       return NeoStats::NS_FAILURE;
     }    
     if ((!exists( $botinfo->{gecos} )) || (!defined( $botinfo->{gecos} ))) {
-      NeoStats::print("Botinfo->{gecos} not defined");
+      NeoStats::debug("Botinfo->{gecos} not defined");
       return NeoStats::NS_FAILURE;
     }    
     
@@ -156,7 +156,7 @@
   }
   sub DelBot {
     if (@_ < 1) {
-      NeoStats::print("Invalid Number of arguments to DelBot");
+      NeoStats::debug("Invalid Number of arguments to DelBot");
       return NeoStats::NS_FAILURE;
     }
     my $botname = shift;
@@ -169,7 +169,7 @@
 
   sub FindUser {
     if (@_ < 1) {
-      NeoStats::print("Invalid Number of arguments to FindUser");
+      NeoStats::debug("Invalid Number of arguments to FindUser");
       return NeoStats::NS_FAILURE;
     }
     my $nick = shift;
@@ -178,7 +178,7 @@
 
   sub FindServer {
     if (@_ < 1) {
-      NeoStats::print("Invalid Number of arguments to FindServer");
+      NeoStats::debug("Invalid Number of arguments to FindServer");
       return NeoStats::NS_FAILURE;
     }
     my $name = shift;
@@ -187,7 +187,7 @@
 
   sub FindChan {
     if (@_ < 1) {
-      NeoStats::print("Invalid Number of arguments to FindChannel");
+      NeoStats::debug("Invalid Number of arguments to FindChannel");
       return NeoStats::NS_FAILURE;
     }
     my $name = shift;
@@ -196,7 +196,7 @@
   
   sub AddCmd {
     if (@_ < 3) {
-      NeoStats::print("Invalid Number of arguments to AddCmd");
+      NeoStats::debug("Invalid Number of arguments to AddCmd");
       return NeoStats::NS_FAILURE;
     }
 
@@ -208,28 +208,28 @@
     $callback = NeoStats::Embed::fix_callback( $package, $callback );
   
     if (!ref( $botcmd ) eq 'HASH' ) {
-      NeoStats::print("Botcmd is not a hash");
+      NeoStats::debug("Botcmd is not a hash");
       return NeoStats::NS_FAILURE;
     }
     if ((!exists( $botcmd->{cmd} )) || (!defined( $botcmd->{cmd} ))) {
-      NeoStats::print("Botinfo->{cmd} not defined");
+      NeoStats::debug("Botinfo->{cmd} not defined");
       return NeoStats::NS_FAILURE;
     }    
     if ((!exists( $botcmd->{minparams} )) || (!defined( $botcmd->{minparams} ))) {
-      NeoStats::print("Botinfo->{minparams} not defined");
+      NeoStats::debug("Botinfo->{minparams} not defined");
       return NeoStats::NS_FAILURE;
     }    
     if ((!exists( $botcmd->{ulevel} )) || (!defined( $botcmd->{ulevel} ))) {
-      NeoStats::print("Bot->{ulevel} not defined");
+      NeoStats::debug("Bot->{ulevel} not defined");
       return NeoStats::NS_FAILURE;
     }    
 #XXX TODO
 #    if ((!exists( $botcmd->{helptext} )) || (!defined( $botcmd->{helptext} ))) {
-#      NeoStats::print("Botinfo->{host} not defined");
+#      NeoStats::debug("Botinfo->{host} not defined");
 #      return NeoStats::NS_FAILURE;
 #    }    
     if ((!exists( $botcmd->{flags} )) || (!defined( $botcmd->{flags} ))) {
-      NeoStats::print("Botinfo->{flags} not defined");
+      NeoStats::debug("Botinfo->{flags} not defined");
       return NeoStats::NS_FAILURE;
     }    
     my $ret =  NeoStats::Internal::AddCommand( $bot, $botcmd, $callback);
@@ -238,16 +238,36 @@
 
   sub DelCmd {
     if (@_ < 2) {
-      NeoStats::print("Invalid Number of arguments to DelCmd");
+      NeoStats::debug("Invalid Number of arguments to DelCmd");
       return NeoStats::NS_FAILURE;
     }
     my $bot = shift;
     my $botcmd = shift;
-NeoStats::print("$bot $botcmd");
     return NeoStats::Internal::DelCommand($bot, $botcmd);
   }
 
-  sub print {
+  sub PrefMsg {
+    if (@_ < 3) {
+      NeoStats::debug("Invalid Number of arguments to PreMsg");
+      return NeoStats::NS_FAILURE;
+    }
+    my $bot = shift;
+    my $target = shift;
+    my $message = shift;
+    return NeoStats::Internal::Prefmsg($bot, $target, $message);
+  }
+
+  sub ChanAlert {
+    if (@_ < 2) {
+      NeoStats::debug("Invalid Number of arguments to ChanAlert");
+      return NeoStats::NS_FAILURE;
+    }
+    my $bot = shift;
+    my $message = shift;
+    return NeoStats::Internal::ChanAlert($bot, $message);
+  }
+
+  sub debug {
 
     my $text = shift @_;
     return 1 unless $text;
@@ -264,7 +284,7 @@
 
   sub printf {
     my $format = shift;
-    NeoStats::print( sprintf( $format, @_ ) );
+    NeoStats::debug( sprintf( $format, @_ ) );
   }
 
   sub strip_code {
@@ -296,7 +316,7 @@
   if( $pkg_info ) {
     $message =~ s/\(eval \d+\)/$pkg_info->{filename}/;
   }
-  NeoStats::print( $message );
+  NeoStats::debug( $message );
 };
 
 {
@@ -353,8 +373,8 @@
 #    if ( exists $scripts{$package} ) {
 #      my $pkg_info = pkg_info( $package );
 #      my $filename = File::Basename::basename( $pkg_info->{filename} );
-#      NeoStats::print( qq{'$filename' already loaded from '$pkg_info->{filename}'.\n} );
-#      NeoStats::print( 'If this is a different script then it rename and try loading it again.' );
+#      NeoStats::debug( qq{'$filename' already loaded from '$pkg_info->{filename}'.\n} );
+#      NeoStats::debug( 'If this is a different script then it rename and try loading it again.' );
 #      return 2;
 #    }
 
@@ -366,7 +386,7 @@
         my $original_package = $1;
 
         if ( $replacements > 1 ) {
-          NeoStats::print( "Too many package defintions, only 1 is allowed\n" );
+          NeoStats::debug( "Too many package defintions, only 1 is allowed\n" );
           return 1;
         }
 
@@ -386,7 +406,7 @@
 
       if ( $@ ) {
         # something went wrong
-        NeoStats::print( "Error loading '$file':\n$@\n" );
+        NeoStats::debug( "Error loading '$file':\n$@\n" );
 
         # make sure the script list doesn't contain false information
         unload( $scripts{$package}{filename} );
@@ -394,7 +414,7 @@
       }
 
     } else {
-      NeoStats::print( "Error opening '$file': $!\n" );
+      NeoStats::debug( "Error opening '$file': $!\n" );
       return 2;
     }
     

Modified: trunk/src/neostats.pm.h
==============================================================================
--- trunk/src/neostats.pm.h	(original)
+++ trunk/src/neostats.pm.h	Mon Aug  1 20:39:14 2005
@@ -44,7 +44,7 @@
 "\n"
 "sub register {\n"
 "if (@_ != 5) {\n"
-"NeoStats::print(\"Invalid Number of arguments to register\");\n"
+"NeoStats::debug(\"Invalid Number of arguments to register\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}\n"
 "my ($package) = caller;\n"
@@ -73,7 +73,7 @@
 "\n"
 "sub hook_event {\n"
 "if (@_ < 2) {\n"
-"NeoStats::print(\"Invalid Number of arguments to hook_event\");\n"
+"NeoStats::debug(\"Invalid Number of arguments to hook_event\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}\n"
 "\n"
@@ -105,7 +105,7 @@
 "}\n"
 "\n"
 "sub unhook_event {\n"
-"NeoStats::print(\"todo\");\n"
+"NeoStats::debug(\"todo\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}\n"
 "\n"
@@ -113,7 +113,7 @@
 "\n"
 "sub AddBot {\n"
 "if (@_ < 2) {\n"
-"NeoStats::print(\"Invalid Number of arguments to AddBot\");\n"
+"NeoStats::debug(\"Invalid Number of arguments to AddBot\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}\n"
 "\n"
@@ -127,23 +127,23 @@
 "return NeoStats::NS_FAILURE;\n"
 "}\n"
 "if ((!exists( $botinfo->{nick} )) || (!defined( $botinfo->{nick} ))) {\n"
-"NeoStats::print(\"Botinfo->{nick} not defined\");\n"
+"NeoStats::debug(\"Botinfo->{nick} not defined\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}    \n"
 "if ((!exists( $botinfo->{altnick} )) || (!defined( $botinfo->{altnick} ))) {\n"
-"NeoStats::print(\"Botinfo->{altnick} not defined\");\n"
+"NeoStats::debug(\"Botinfo->{altnick} not defined\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}    \n"
 "if ((!exists( $botinfo->{ident} )) || (!defined( $botinfo->{ident} ))) {\n"
-"NeoStats::print(\"Botinfo->{ident} not defined\");\n"
+"NeoStats::debug(\"Botinfo->{ident} not defined\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}    \n"
 "if ((!exists( $botinfo->{host} )) || (!defined( $botinfo->{host} ))) {\n"
-"NeoStats::print(\"Botinfo->{host} not defined\");\n"
+"NeoStats::debug(\"Botinfo->{host} not defined\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}    \n"
 "if ((!exists( $botinfo->{gecos} )) || (!defined( $botinfo->{gecos} ))) {\n"
-"NeoStats::print(\"Botinfo->{gecos} not defined\");\n"
+"NeoStats::debug(\"Botinfo->{gecos} not defined\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}    \n"
 "\n"
@@ -156,7 +156,7 @@
 "}\n"
 "sub DelBot {\n"
 "if (@_ < 1) {\n"
-"NeoStats::print(\"Invalid Number of arguments to DelBot\");\n"
+"NeoStats::debug(\"Invalid Number of arguments to DelBot\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}\n"
 "my $botname = shift;\n"
@@ -169,7 +169,7 @@
 "\n"
 "sub FindUser {\n"
 "if (@_ < 1) {\n"
-"NeoStats::print(\"Invalid Number of arguments to FindUser\");\n"
+"NeoStats::debug(\"Invalid Number of arguments to FindUser\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}\n"
 "my $nick = shift;\n"
@@ -178,7 +178,7 @@
 "\n"
 "sub FindServer {\n"
 "if (@_ < 1) {\n"
-"NeoStats::print(\"Invalid Number of arguments to FindServer\");\n"
+"NeoStats::debug(\"Invalid Number of arguments to FindServer\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}\n"
 "my $name = shift;\n"
@@ -187,7 +187,7 @@
 "\n"
 "sub FindChan {\n"
 "if (@_ < 1) {\n"
-"NeoStats::print(\"Invalid Number of arguments to FindChannel\");\n"
+"NeoStats::debug(\"Invalid Number of arguments to FindChannel\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}\n"
 "my $name = shift;\n"
@@ -196,7 +196,7 @@
 "\n"
 "sub AddCmd {\n"
 "if (@_ < 3) {\n"
-"NeoStats::print(\"Invalid Number of arguments to AddCmd\");\n"
+"NeoStats::debug(\"Invalid Number of arguments to AddCmd\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}\n"
 "\n"
@@ -208,19 +208,19 @@
 "$callback = NeoStats::Embed::fix_callback( $package, $callback );\n"
 "\n"
 "if (!ref( $botcmd ) eq 'HASH' ) {\n"
-"NeoStats::print(\"Botcmd is not a hash\");\n"
+"NeoStats::debug(\"Botcmd is not a hash\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}\n"
 "if ((!exists( $botcmd->{cmd} )) || (!defined( $botcmd->{cmd} ))) {\n"
-"NeoStats::print(\"Botinfo->{cmd} not defined\");\n"
+"NeoStats::debug(\"Botinfo->{cmd} not defined\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}    \n"
 "if ((!exists( $botcmd->{minparams} )) || (!defined( $botcmd->{minparams} ))) {\n"
-"NeoStats::print(\"Botinfo->{minparams} not defined\");\n"
+"NeoStats::debug(\"Botinfo->{minparams} not defined\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}    \n"
 "if ((!exists( $botcmd->{ulevel} )) || (!defined( $botcmd->{ulevel} ))) {\n"
-"NeoStats::print(\"Bot->{ulevel} not defined\");\n"
+"NeoStats::debug(\"Bot->{ulevel} not defined\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}    \n"
 "\n"
@@ -229,7 +229,7 @@
 "\n"
 "\n"
 "if ((!exists( $botcmd->{flags} )) || (!defined( $botcmd->{flags} ))) {\n"
-"NeoStats::print(\"Botinfo->{flags} not defined\");\n"
+"NeoStats::debug(\"Botinfo->{flags} not defined\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}    \n"
 "my $ret =  NeoStats::Internal::AddCommand( $bot, $botcmd, $callback);\n"
@@ -238,16 +238,36 @@
 "\n"
 "sub DelCmd {\n"
 "if (@_ < 2) {\n"
-"NeoStats::print(\"Invalid Number of arguments to DelCmd\");\n"
+"NeoStats::debug(\"Invalid Number of arguments to DelCmd\");\n"
 "return NeoStats::NS_FAILURE;\n"
 "}\n"
 "my $bot = shift;\n"
 "my $botcmd = shift;\n"
-"NeoStats::print(\"$bot $botcmd\");\n"
 "return NeoStats::Internal::DelCommand($bot, $botcmd);\n"
 "}\n"
 "\n"
-"sub print {\n"
+"sub PrefMsg {\n"
+"if (@_ < 3) {\n"
+"NeoStats::debug(\"Invalid Number of arguments to PreMsg\");\n"
+"return NeoStats::NS_FAILURE;\n"
+"}\n"
+"my $bot = shift;\n"
+"my $target = shift;\n"
+"my $message = shift;\n"
+"return NeoStats::Internal::Prefmsg($bot, $target, $message);\n"
+"}\n"
+"\n"
+"sub ChanAlert {\n"
+"if (@_ < 2) {\n"
+"NeoStats::debug(\"Invalid Number of arguments to ChanAlert\");\n"
+"return NeoStats::NS_FAILURE;\n"
+"}\n"
+"my $bot = shift;\n"
+"my $message = shift;\n"
+"return NeoStats::Internal::ChanAlert($bot, $message);\n"
+"}\n"
+"\n"
+"sub debug {\n"
 "\n"
 "my $text = shift @_;\n"
 "return 1 unless $text;\n"
@@ -264,7 +284,7 @@
 "\n"
 "sub printf {\n"
 "my $format = shift;\n"
-"NeoStats::print( sprintf( $format, @_ ) );\n"
+"NeoStats::debug( sprintf( $format, @_ ) );\n"
 "}\n"
 "\n"
 "sub strip_code {\n"
@@ -296,7 +316,7 @@
 "if( $pkg_info ) {\n"
 "$message =~ s/\\(eval \\d+\\)/$pkg_info->{filename}/;\n"
 "}\n"
-"NeoStats::print( $message );\n"
+"NeoStats::debug( $message );\n"
 "};\n"
 "\n"
 "{\n"
@@ -366,7 +386,7 @@
 "my $original_package = $1;\n"
 "\n"
 "if ( $replacements > 1 ) {\n"
-"NeoStats::print( \"Too many package defintions, only 1 is allowed\\n\" );\n"
+"NeoStats::debug( \"Too many package defintions, only 1 is allowed\\n\" );\n"
 "return 1;\n"
 "}\n"
 "\n"
@@ -386,7 +406,7 @@
 "\n"
 "if ( $@ ) {\n"
 "\n"
-"NeoStats::print( \"Error loading '$file':\\n$@\\n\" );\n"
+"NeoStats::debug( \"Error loading '$file':\\n$@\\n\" );\n"
 "\n"
 "\n"
 "unload( $scripts{$package}{filename} );\n"
@@ -394,7 +414,7 @@
 "}\n"
 "\n"
 "} else {\n"
-"NeoStats::print( \"Error opening '$file': $!\\n\" );\n"
+"NeoStats::debug( \"Error opening '$file': $!\\n\" );\n"
 "return 2;\n"
 "}\n"
 "\n"

Modified: trunk/src/perl.c
==============================================================================
--- trunk/src/perl.c	(original)
+++ trunk/src/perl.c	Mon Aug  1 20:39:14 2005
@@ -300,8 +300,7 @@
 
 int
 perl_command_cb(CmdParams *cmdparams) {
-
-	return NS_SUCCESS;
+	return execute_perl(cmdparams->bot->moduleptr, sv_2mortal (newSVpv (cmdparams->cmd_ptr->moddata, 0)), 3, cmdparams->cmd_ptr->cmd, cmdparams->source->name, cmdparams->param);
 }
 
 
@@ -448,7 +447,7 @@
 
 	dXSARGS;
 	if (items != 1) {
-		nlog(LOG_WARNING, "Usage: NeoStats::Internal::print(text)");
+		nlog(LOG_WARNING, "Usage: NeoStats::Internal::debug(text)");
 	} else {
 		text = SvPV_nolen (ST (0));
 		nlog(LOG_WARNING, "%s", text);
@@ -530,7 +529,9 @@
 			 XSRETURN_EMPTY;
 		}
 		rethash = (HV*)SvRV(ret);
+#ifdef DEBUG
 		dump_hash(rethash);
+#endif
 		bi = ns_malloc(sizeof(BotInfo));
 		value = *hv_fetch(rethash, "nick", strlen("nick"), FALSE);
 		strncpy(bi->nick, SvPV_nolen(value), MAXNICK);
@@ -698,7 +699,9 @@
 			 XSRETURN_EMPTY;
 		}
 		rethash = (HV*)SvRV(ret);
+#ifdef DEBUG
 		dump_hash(rethash);
+#endif
 		bc = ns_malloc(sizeof(bot_cmd));
 		value = *hv_fetch(rethash, "cmd", strlen("cmd"), FALSE);
 		bc->cmd = malloc(SvLEN(value)+1);
@@ -752,6 +755,50 @@
 	XSRETURN_UV(NS_FAILURE);
 }
 
+static
+XS (XS_NeoStats_Prefmsg)
+{
+	Module *mod;
+	Bot *bot;
+	Client *u;
+
+	dXSARGS;
+	mod = GET_CUR_MODULE();
+	if (items < 3) {
+		nlog(LOG_WARNING, "Usage: NeoStats:Internal:Prefmsg(from, to, message)");
+	} else {
+		bot = FindBot(SvPV_nolen(ST(0)));
+		u = FindUser(SvPV_nolen(ST(1)));
+		if (bot && u) {
+			irc_prefmsg(bot, u, "%s", SvPV_nolen(ST(2)));
+			return XSRETURN_UV(NS_SUCCESS);
+		}
+		
+	}
+	XSRETURN_UV(NS_FAILURE);
+}
+
+static
+XS (XS_NeoStats_ChanAlert)
+{
+	Module *mod;
+	Bot *bot;
+
+	dXSARGS;
+	mod = GET_CUR_MODULE();
+	if (items < 2) {
+		nlog(LOG_WARNING, "Usage: NeoStats:Internal:ChanAlert(from, message)");
+	} else {
+		bot = FindBot(SvPV_nolen(ST(0)));
+		if (bot) {
+			irc_chanalert(bot, "%s", SvPV_nolen(ST(1)));
+			return XSRETURN_UV(NS_SUCCESS);
+		}
+		
+	}
+	XSRETURN_UV(NS_FAILURE);
+}
+
 
 #if 0
 
@@ -876,6 +923,8 @@
 	newXS ("NeoStats::Internal::FindChannel", XS_NeoStats_FindChannel, __FILE__);
 	newXS ("NeoStats::Internal::AddCommand", XS_NeoStats_AddCommand, __FILE__);
 	newXS ("NeoStats::Internal::DelCommand", XS_NeoStats_DelCommand, __FILE__);
+	newXS ("NeoStats::Internal::Prefmsg", XS_NeoStats_Prefmsg, __FILE__);
+	newXS ("NeoStats::Internal::ChanAlert", XS_NeoStats_ChanAlert, __FILE__);
 
 	stash = get_hv ("NeoStats::", TRUE);
 	if (stash == NULL) {
@@ -947,6 +996,12 @@
 	newCONSTSUB (stash, "BOT_FLAG_NOINTRINSICLEVELS", newSViv (BOT_FLAG_NOINTRINSICLEVELS));
 	newCONSTSUB (stash, "BOT_COMMON_HOST", newSVpv (BOT_COMMON_HOST, strlen(BOT_COMMON_HOST)));
 
+	newCONSTSUB (stash, "NS_ERR_SYNTAX_ERROR", newSViv (NS_ERR_SYNTAX_ERROR));
+	newCONSTSUB (stash, "NS_ERR_NEED_MORE_PARAMS", newSViv(NS_ERR_NEED_MORE_PARAMS));
+	newCONSTSUB (stash, "NS_ERR_PARAM_OUT_OF_RANGE", newSViv(NS_ERR_PARAM_OUT_OF_RANGE));
+	newCONSTSUB (stash, "NS_ERR_UNKNOWN_COMMAND", newSViv(NS_ERR_UNKNOWN_COMMAND));
+	newCONSTSUB (stash, "NS_ERR_NO_PERMISSION", newSViv(NS_ERR_NO_PERMISSION));
+	
 
 
 	newCONSTSUB (stash, "NS_SUCCESS", newSViv (NS_SUCCESS));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.