[SimBot-commits] CVS: simbot/plugins 8ball.pl,1.4,1.5 aspell.pl,1.7,1.8 dice.pl,1.23,1.24 dict.pl,1.
Status: Abandoned
Brought to you by:
kstange
|
From: Kevin S. <ks...@us...> - 2005-11-10 13:02:27
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23423/plugins Modified Files: 8ball.pl aspell.pl dice.pl dict.pl error.pl google.pl httpd.pl info.pl nlp.pl recap.pl rss.pl services.chanserv.pl services.undernet.pl sqlite-logger.pl time.pl tinyurl.pl todo.pl weather.pl Log Message: Added SimBot::Util module which is now used by literally everything. It's nice because it allows the plugins to use in their namespace several handy utility functions, while also allowing us to truly hide functions and variables that plugins shouldn't be accessing directly. This module can also be used by scripts in tools/ if they should want to use any utility functions we have created. It is a completely independent perl module. I will likely be adding SimBot::Plugin and attempting to migrate the plugin functions and data into that file if possible as my next step. The other thing I'd like to do fairly soon is get the main database into SQLite. We'll see... :) Index: 8ball.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/8ball.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- 8ball.pl 14 Aug 2005 01:42:34 -0000 1.4 +++ 8ball.pl 10 Nov 2005 13:02:15 -0000 1.5 @@ -20,6 +20,9 @@ package SimBot::plugin::8ball; use warnings; use strict; +# Use the SimBot Util perl module +use SimBot::Util; + # http://en.wikipedia.org/wiki/Magic_8-ball use constant SAYINGS => ( 'Signs point to yes.', @@ -62,15 +65,15 @@ use constant BLANK_INTROS => sub consult_the_8ball { my ( $kernel, $nick, $channel, undef, $question ) = @_; - &SimBot::debug( 3, "8ball: Consulting the Magic Eight Ball for $nick\n" ); + &debug( 3, "8ball: Consulting the Magic Eight Ball for $nick\n" ); my $message; if ( defined $question ) { - $message = &SimBot::pick( (INTROS) ) . ' ' . &SimBot::pick( (SAYINGS) ); + $message = &pick( (INTROS) ) . ' ' . &pick( (SAYINGS) ); } else { $message = - &SimBot::pick( (BLANK_INTROS) ) . ' ' . &SimBot::pick( (BLANK_SAYINGS) ); + &pick( (BLANK_INTROS) ) . ' ' . &pick( (BLANK_SAYINGS) ); } $message =~ s/\$nick/$nick/g; Index: aspell.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/aspell.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -p -r1.7 -r1.8 --- aspell.pl 25 Jul 2005 09:34:18 -0000 1.7 +++ aspell.pl 10 Nov 2005 13:02:15 -0000 1.8 @@ -38,6 +38,9 @@ use constant CORRECT_SPELLING_BONUS => 0 use warnings; use strict; +# Use the SimBot Util perl module +use SimBot::Util; + use Text::Aspell; use vars qw( $SPELLER %DICTS ); @@ -46,8 +49,8 @@ use vars qw( $SPELLER %DICTS ); sub messup_aspell { $SPELLER = Text::Aspell->new or die "Could not create speller"; $SPELLER->set_option('sug-mode', SUGGESTION_MODE); - $SPELLER->set_option('lang', (&SimBot::option('plugin.aspell', 'lang') - ? &SimBot::option('plugin.aspell', 'lang') + $SPELLER->set_option('lang', (&option('plugin.aspell', 'lang') + ? &option('plugin.aspell', 'lang') : 'en')); my $cur; @@ -100,7 +103,7 @@ sub score_word { my $word = $_[1]; my $score = $_[2]; if($SPELLER->check($word)) { - &SimBot::debug(4, "$word:+" . int(CORRECT_SPELLING_BONUS * $score) . '(aspell) ', SimBot::DEBUG_NO_PREFIX); + &debug(4, "$word:+" . int(CORRECT_SPELLING_BONUS * $score) . '(aspell) ', DEBUG_NO_PREFIX); return int(CORRECT_SPELLING_BONUS * $score); } } Index: dice.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/dice.pl,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -p -r1.23 -r1.24 --- dice.pl 4 May 2005 21:09:54 -0000 1.23 +++ dice.pl 10 Nov 2005 13:02:15 -0000 1.24 @@ -32,6 +32,9 @@ package SimBot::plugin::roll; use strict; use warnings; +# Use the SimBot Util perl module +use SimBot::Util; + # Jeers for Rock Paper Scissors use constant RPS_JEER => ( 'Oh, the horror!', @@ -107,27 +110,27 @@ sub rps_shoot { if (!defined $object || $object eq "") { &SimBot::send_message($channel, "$nick: Well? Rock, paper, or scissors?"); } elsif ($object =~ /^(rock|paper|scissors)$/) { - my $pick = &SimBot::pick(('rock', 'paper','scissors')); + my $pick = &pick(('rock', 'paper','scissors')); $text = "$nick: I picked: $pick. "; if ($pick eq $object) { $text .= "It's a draw! Try again!"; } elsif ($object eq "rock") { if ($pick eq "scissors") { - $text .= "Your rock smashed my scissors. " . &SimBot::pick(RPS_JEER) . " You win!"; + $text .= "Your rock smashed my scissors. " . &pick(RPS_JEER) . " You win!"; } elsif ($pick eq "paper") { - $text .= "My paper covered your rock. " . &SimBot::pick(RPS_CHEER) . " I win!"; + $text .= "My paper covered your rock. " . &pick(RPS_CHEER) . " I win!"; } } elsif ($object eq "paper") { if ($pick eq "rock") { - $text .= "Your paper covered my rock. " . &SimBot::pick((RPS_JEER)) . " You win!"; + $text .= "Your paper covered my rock. " . &pick((RPS_JEER)) . " You win!"; } elsif ($pick eq "scissors") { - $text .= "My scissors cut your paper. " . &SimBot::pick((RPS_CHEER)) . " I win!"; + $text .= "My scissors cut your paper. " . &pick((RPS_CHEER)) . " I win!"; } } elsif ($object eq "scissors") { if ($pick eq "paper") { - $text .= "Your scissors cut my paper. " . &SimBot::pick((RPS_JEER)) . " You win!"; + $text .= "Your scissors cut my paper. " . &pick((RPS_JEER)) . " You win!"; } elsif ($pick eq "rock") { - $text .= "My rock smashed your scissors. " . &SimBot::pick((RPS_CHEER)) . " I win!"; + $text .= "My rock smashed your scissors. " . &pick((RPS_CHEER)) . " I win!"; } } &SimBot::send_message($channel, $text); Index: dict.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/dict.pl,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -p -r1.20 -r1.21 --- dict.pl 5 May 2005 03:48:46 -0000 1.20 +++ dict.pl 10 Nov 2005 13:02:15 -0000 1.21 @@ -22,6 +22,9 @@ package SimBot::plugin::define; use strict; use warnings; +# Use the SimBot Util perl module +use SimBot::Util; + # Support for the Dict protocol is found here: use Net::Dict; @@ -44,15 +47,15 @@ sub look_up { $destination = (defined $6 ? $6 : "default"); } - &SimBot::debug(3, "define: Received request from " . $nick . ".\n"); + &debug(3, "define: Received request from " . $nick . ".\n"); my $dict = Net::Dict->new(DICT_SERVER, - Client => SimBot::PROJECT . " " . SimBot::VERSION, + Client => PROJECT . " " . VERSION, Timeout => 10, ); if (!defined $dict) { - &SimBot::debug(1, "define: Unable to connect to " . DICT_SERVER . "dictionary server.\n"); + &debug(1, "define: Unable to connect to " . DICT_SERVER . "dictionary server.\n"); &SimBot::send_message($channel, "$nick: The dictionary server was unavailable."); return; } @@ -95,11 +98,11 @@ sub look_up { my $definition = ${${$def}[0]}[1]; $dictionary = ${${$def}[0]}[0]; $definition =~ s/\s+/ /g; - $definition = &SimBot::parse_style("%uline%From the $dbs{$dictionary}:%uline% $definition"); + $definition = &parse_style("%uline%From the $dbs{$dictionary}:%uline% $definition"); if ((length($definition) > 440 && $destination eq "default") || (length($definition) > 1320 && $destination eq "publicly")) { - &SimBot::send_message($channel, &SimBot::parse_style("$nick: I found a definition in the $dbs{$dictionary}, but it is too long to display in the channel. Type %bold%" . $command . " \"$term\" in $dictionary privately%bold% to see it privately.")); + &SimBot::send_message($channel, &parse_style("$nick: I found a definition in the $dbs{$dictionary}, but it is too long to display in the channel. Type %bold%" . $command . " \"$term\" in $dictionary privately%bold% to see it privately.")); } elsif ($destination eq "publicly") { &SimBot::send_pieces($channel, "$nick:", $definition); } elsif ($destination eq "privately") { @@ -128,7 +131,7 @@ sub look_up { } } else { - &SimBot::send_message($channel, &SimBot::parse_style("$nick: There is no dictionary called '$dictionary' available. Type %bold%$command%bold% with no parameters to see a list of dictionaries you can use.")); + &SimBot::send_message($channel, &parse_style("$nick: There is no dictionary called '$dictionary' available. Type %bold%$command%bold% with no parameters to see a list of dictionaries you can use.")); } } Index: error.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/error.pl,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -p -r1.12 -r1.13 --- error.pl 6 May 2005 21:10:26 -0000 1.12 +++ error.pl 10 Nov 2005 13:02:15 -0000 1.13 @@ -20,13 +20,16 @@ package SimBot::plugin::error; use strict; use warnings; +# Use the SimBot Util perl module +use SimBot::Util; + sub random_error { my ($kernel, $nick, $channel) = @_; - &SimBot::debug(3, "error: Got error request from " . $nick . ".\n"); + &debug(3, "error: Got error request from " . $nick . ".\n"); open(FILE, "data/errors.db"); my @lines = <FILE>; close(FILE); - my $error = &SimBot::pick(@lines); + my $error = &pick(@lines); chomp($error); $error =~ s/\$nick/$nick/g; &SimBot::send_message($channel, $error); @@ -34,7 +37,7 @@ sub random_error { sub random_quip { my ($nick, $channel) = @_[1,2]; - &SimBot::debug(3, "error: Got list request from " . $nick . ".\n"); + &debug(3, "error: Got list request from " . $nick . ".\n"); my @reply = ( "$nick: HER R TEH FIL3Z!!!! TEH PR1Z3 FOR U! KTHXBYE", "$nick: U R L33T H4X0R!", @@ -45,7 +48,7 @@ sub random_quip { "$nick: Ur Leet-Foo is weak!", "$nick: Like a dagger in teh nite, I catch joo unawarez!", ); - &SimBot::send_message($channel, &SimBot::pick(@reply)); + &SimBot::send_message($channel, &pick(@reply)); } # Register Plugin Index: google.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/google.pl,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -p -r1.20 -r1.21 --- google.pl 13 May 2005 02:03:22 -0000 1.20 +++ google.pl 10 Nov 2005 13:02:15 -0000 1.21 @@ -20,6 +20,9 @@ package SimBot::plugin::find; use strict; use warnings; +# Use the SimBot Util perl module +use SimBot::Util; + # We need these to work with HTML and HTTP use LWP::UserAgent; use HTML::Entities; @@ -30,7 +33,7 @@ sub google_find { shift(@terms); my $query = "@terms"; - &SimBot::debug(3, "google: Got request from " . $nick . ".\n"); + &debug(3, "google: Got request from " . $nick . ".\n"); if (!$query) { &SimBot::send_message($channel, "$nick: Nothing was found. I didn't look, but I think that was a safe bet."); @@ -43,7 +46,7 @@ sub google_find { $query =~ s/\s/+/g; my $url = "http://www.google.com/search?q=" . $query . "&btnI=1&safe=active"; my $useragent = LWP::UserAgent->new(requests_redirectable => undef); - $useragent->agent(SimBot::PROJECT . "/" . SimBot::VERSION); + $useragent->agent(PROJECT . "/" . VERSION); $useragent->timeout(5); my $request = HTTP::Request->new(GET => $url); my $response = $useragent->request($request); Index: httpd.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/httpd.pl,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -p -r1.20 -r1.21 --- httpd.pl 13 Aug 2005 19:20:35 -0000 1.20 +++ httpd.pl 10 Nov 2005 13:02:15 -0000 1.21 @@ -20,6 +20,9 @@ package SimBot::plugin::httpd; use warnings; use strict; +# Use the SimBot Util perl module +use SimBot::Util; + use POE; use POE::Component::Server::TCP; use POE::Filter::HTTPD; @@ -32,8 +35,8 @@ use vars qw( $kernel ); POE::Component::Server::TCP->new( Alias => 'web_server', Port => ( - defined &SimBot::option( 'plugin.httpd', 'port' ) - ? &SimBot::option( 'plugin.httpd', 'port' ) + defined &option( 'plugin.httpd', 'port' ) + ? &option( 'plugin.httpd', 'port' ) : 8000 ), ClientFilter => 'POE::Filter::HTTPD', @@ -56,7 +59,7 @@ sub index_handler { my ($req_root) = $request->uri =~ m|^/([^/\?]*)|; - &SimBot::debug( 3, + &debug( 3, 'httpd: handling request for ' . $request->uri . ", req root $req_root\n" ); @@ -137,7 +140,7 @@ sub get_template { } elsif ( -r "templates/${template}.default.tmpl" ) { $file_name = "templates/${template}.default.tmpl"; } else { - &SimBot::debug( &SimBot::DEBUG_WARN, + &debug( &DEBUG_WARN, "httpd: No template $template available!\n" ); return; } @@ -149,8 +152,8 @@ sub get_template { loop_context_vars => 1, ); $templ_obj->param( - sb_version => &SimBot::PROJECT . ' ' . &SimBot::VERSION, - sb_link => &SimBot::HOME_PAGE, + sb_version => &PROJECT . ' ' . &VERSION, + sb_link => &HOME_PAGE, ); return $templ_obj; } ## end sub get_template @@ -158,8 +161,8 @@ sub get_template { sub admin_page { my ( $request, $response ) = @_; - if ( !defined &SimBot::option( 'plugin.httpd', 'admin_pass' ) ) { - &SimBot::debug( &SimBot::DEBUG_WARN, + if ( !defined &option( 'plugin.httpd', 'admin_pass' ) ) { + &debug( &DEBUG_WARN, "httpd: in admin_page with no password defined!\n" ); return 500; # internal server error } @@ -170,8 +173,8 @@ sub admin_page { return RC_UNAUTHORIZED; } my ( $user, $pass ) = $request->authorization_basic; - if ( $user ne &SimBot::option( 'plugin.httpd', 'admin_user' ) - || $pass ne &SimBot::option( 'plugin.httpd', 'admin_pass' ) ) + if ( $user ne &option( 'plugin.httpd', 'admin_user' ) + || $pass ne &option( 'plugin.httpd', 'admin_pass' ) ) { $response->www_authenticate('Basic realm="simbot admin"'); @@ -192,13 +195,13 @@ sub admin_page { } elsif ( ($say) = $request->uri =~ m|\?say=(\S+)$| ) { $say =~ s/\+/ /g; $say =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; - &SimBot::debug( 3, "Speech requested by web admin\n" ); - &SimBot::send_message( &SimBot::option( 'network', 'channel' ), $say ); + &debug( 3, "Speech requested by web admin\n" ); + &SimBot::send_message( &option( 'network', 'channel' ), $say ); } elsif ( ($say) = $request->uri =~ m|\?action=(\S+)$| ) { $say =~ s/\+/ /g; $say =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; - &SimBot::debug( 3, "Action requested by web admin\n" ); - &SimBot::send_action( &SimBot::option( 'network', 'channel' ), $say ); + &debug( 3, "Action requested by web admin\n" ); + &SimBot::send_action( &option( 'network', 'channel' ), $say ); } $msg .= '<ul><li><a href="/admin?restart">Restart Simbot</a></li>'; $msg .= @@ -249,10 +252,10 @@ sub serve_css { } ## end sub serve_css sub messup_httpd { - if ( defined &SimBot::option( 'plugin.httpd', 'admin_user' ) - && length &SimBot::option( 'plugin.httpd', 'admin_user' ) > 4 - && defined &SimBot::option( 'plugin.httpd', 'admin_pass' ) - && length &SimBot::option( 'plugin.httpd', 'admin_pass' ) > 4 ) + if ( defined &option( 'plugin.httpd', 'admin_user' ) + && length &option( 'plugin.httpd', 'admin_user' ) > 4 + && defined &option( 'plugin.httpd', 'admin_pass' ) + && length &option( 'plugin.httpd', 'admin_pass' ) > 4 ) { $SimBot::hash_plugin_httpd_pages{'admin'} = { 'title' => 'SimBot Administration', @@ -263,9 +266,9 @@ sub messup_httpd { } sub cleanup_httpd { - &SimBot::debug( 3, "httpd: Shutting down..." ); + &debug( 3, "httpd: Shutting down..." ); POE::Kernel->call( 'web_server', 'shutdown' ); - &SimBot::debug( 3, " ok\n" ); + &debug( 3, " ok\n" ); } &SimBot::plugin_register( Index: info.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/info.pl,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -p -r1.44 -r1.45 --- info.pl 16 Aug 2005 17:18:56 -0000 1.44 +++ info.pl 10 Nov 2005 13:02:15 -0000 1.45 @@ -40,10 +40,13 @@ package SimBot::plugin::info; use warnings; use strict; +# Use the SimBot Util perl module +use SimBot::Util; + # Let's declare our globals. use vars qw( %info ); -use constant CMD_PREFIX => SimBot::option( 'global', 'command_prefix' ); +use constant CMD_PREFIX => option( 'global', 'command_prefix' ); # These constants define the phrases simbot will use when responding # to queries. use constant I_DONT_KNOW => ( @@ -154,7 +157,7 @@ sub handle_chat { $person_being_referenced = $1; } if ($being_addressed) { - $person_being_referenced = &SimBot::option( 'global', 'nickname' ); + $person_being_referenced = &option( 'global', 'nickname' ); } if ( $SimBot::snooze && !$being_addressed ) { @@ -175,7 +178,7 @@ sub handle_chat { if ( $info{$key} ) { delete $info{$key}; - &SimBot::debug( 4, "info: Forgot $key (req'd by $nick)\n" ); + &debug( 4, "info: Forgot $key (req'd by $nick)\n" ); &SimBot::send_message( $channel, &parse_message( &SimBot::pick(OK_FORGOTTEN), $nick, $key ) ); } else { @@ -248,7 +251,7 @@ sub handle_chat { &SimBot::send_message( $channel, &parse_message( - &SimBot::pick(BUT_X_IS_MANY), + &pick(BUT_X_IS_MANY), $nick, $key ) ); @@ -264,7 +267,7 @@ sub handle_chat { &SimBot::send_message( $channel, &parse_message( - &SimBot::pick(BUT_X_IS_Y), + &pick(BUT_X_IS_Y), $nick, $key, $isare, $oldFactoid ) ); @@ -298,10 +301,10 @@ sub handle_chat { # if the line contains something on simbot's block list, we # refuse to learn it. If we are being addressed, we give a # nondescript error message. - foreach ( &SimBot::option_list('filters') ) { + foreach ( &option_list('filters') ) { if ( $content =~ /$_/i ) { &SimBot::send_message( $channel, - &parse_message( &SimBot::pick(I_CANNOT), $nick ) ) + &parse_message( &pick(I_CANNOT), $nick ) ) if $being_addressed; return; } @@ -311,7 +314,7 @@ sub handle_chat { &SimBot::send_message( $channel, &parse_message( - &SimBot::pick(X_IS_X), + &pick(X_IS_X), $nick, $key, $isare, $factoid ) ) @@ -336,7 +339,7 @@ sub handle_chat { if ( $info{$key} =~ m/\|\|/ ) { # multiple keys &SimBot::send_message( $channel, - &parse_message( &SimBot::pick(BUT_X_IS_MANY), $nick, $key ) + &parse_message( &pick(BUT_X_IS_MANY), $nick, $key ) ); } else { my ( $keyFlags, $oldFactoid ) = split( /\|/, $info{$key}, 2 ); @@ -349,7 +352,7 @@ sub handle_chat { &SimBot::send_message( $channel, &parse_message( - &SimBot::pick(BUT_X_IS_Y), + &pick(BUT_X_IS_Y), $nick, $key, $isare, $oldFactoid ) ); @@ -416,7 +419,7 @@ sub handle_query { if ( !@factoids ) { @factoids = split( /\|\|/, $info{$query} ); } } ## end if ( ( $flags & PREFER_LOCATION... - ( $factFlags, $factoid ) = split( /\|/, &SimBot::pick(@factoids), 2 ); + ( $factFlags, $factoid ) = split( /\|/, &pick(@factoids), 2 ); my $isare = 'is'; if ( $factFlags & FACT_ARE ) { $isare = 'are'; } @@ -434,14 +437,14 @@ sub handle_query { &SimBot::send_message( $channel, &parse_message( - &SimBot::pick(QUERY_RESPONSE), + &pick(QUERY_RESPONSE), $nick, $query, $isare, $factoid ) ); } elsif ( $flags & BEING_ADDRESSED ) { # we're being addressed, but don't have an answer... &SimBot::send_message( $channel, - &parse_message( &SimBot::pick(I_DONT_KNOW), $nick, $query ) ); + &parse_message( &pick(I_DONT_KNOW), $nick, $query ) ); } } ## end sub handle_query @@ -466,9 +469,9 @@ sub report_learned { else { $flagTxt = '=is=>'; } if ( $flags & FACT_URL ) { $flagTxt .= ' =url='; } - &SimBot::debug( 4, "info: Learning from $nick: $key $flagTxt $factoid\n" ); + &debug( 4, "info: Learning from $nick: $key $flagTxt $factoid\n" ); &SimBot::send_message( $channel, - &parse_message( &SimBot::pick(OK_LEARNED), $nick ) + &parse_message( &pick(OK_LEARNED), $nick ) . " ($key $flagTxt $factoid)" ) if ( $flags & BEING_ADDRESSED ); } ## end sub report_learned @@ -489,7 +492,7 @@ sub report_learned { sub parse_message { my ( $message, $nick, $key, $isare, $factoid ) = @_; - $message = &SimBot::parse_style($message); + $message = &parse_style($message); $message =~ s/\$nick/$nick/g; $message =~ s/\$key/$key/g; Index: nlp.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/nlp.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -p -r1.7 -r1.8 --- nlp.pl 13 Apr 2005 00:06:51 -0000 1.7 +++ nlp.pl 10 Nov 2005 13:02:15 -0000 1.8 @@ -22,6 +22,9 @@ package SimBot::plugin::nlp; use strict; use warnings; +# Use the SimBot Util perl module +use SimBot::Util; + # This function is called back from IRC when it seems that someone is trying # to address the bot. We have a lot to do when that happens. sub process_nlp { @@ -31,7 +34,7 @@ sub process_nlp { my $succeeded_plugin; my $acted = 0; - &SimBot::debug(5, "nlp: full string: $request\n"); + &debug(5, "nlp: full string: $request\n"); # We split on these words in order to break requests up into potentially # several pieces. This allows our processor to recognize more than one @@ -41,7 +44,7 @@ sub process_nlp { foreach my $text (@requests) { next if (!defined $text); - &SimBot::debug(5, "nlp: this segment: $text\n"); + &debug(5, "nlp: this segment: $text\n"); my @matches = (); my @still_matches = (); @@ -51,9 +54,9 @@ sub process_nlp { # If we find none of the verbs requested by a plugin, we don't let # the plugin on to the next round. foreach my $plugin (keys (%{SimBot::hash_plugin_nlp_verbs})) { - &SimBot::debug(5, "nlp: current plugin: $plugin\n"); + &debug(5, "nlp: current plugin: $plugin\n"); foreach my $verb (@{${SimBot::hash_plugin_nlp_verbs}{$plugin}}) { - &SimBot::debug(5, "nlp: current verb: $verb\n"); + &debug(5, "nlp: current verb: $verb\n"); my $verbmatch = $verb . "|" . $verb . "s|" . $verb . "ed|" @@ -65,7 +68,7 @@ sub process_nlp { } } - &SimBot::debug(5, "nlp: verbs passed for: " . join(" ", @matches) . "\n"); + &debug(5, "nlp: verbs passed for: " . join(" ", @matches) . "\n"); # If no plugins are worthy, we'll forget about this segment of the # request right now and skip to the next. If we had a plugin that @@ -172,7 +175,7 @@ sub process_nlp { $type = "command"; } - &SimBot::debug(5, "nlp: query type: $type\n"); + &debug(5, "nlp: query type: $type\n"); # Now we want to eliminate any plugins that don't want queries of # the type we decided we have in this query. This could be carried @@ -189,7 +192,7 @@ sub process_nlp { @matches = @still_matches; @still_matches = (); - &SimBot::debug(5, "nlp: queries passed for: " . join(" ", @matches) . "\n"); + &debug(5, "nlp: queries passed for: " . join(" ", @matches) . "\n"); # If we have no plugins that want the request type and verbs we've # found, let's get the next segment and try again. @@ -216,7 +219,7 @@ sub process_nlp { @matches = @still_matches; @still_matches = (); - &SimBot::debug(5, "nlp: subjects passed for: " . join(" ", @matches) . "\n"); + &debug(5, "nlp: subjects passed for: " . join(" ", @matches) . "\n"); # If no plugins' subjects matched, we'll give up here, and get the # next text segment and test that. @@ -231,7 +234,7 @@ sub process_nlp { # decide which information is relevant or has the highest priority. # Convert word-form numbers into digit-based numbers: - $text = &SimBot::numberize($text); + $text = &numberize($text); foreach my $plugin (@matches) { my @params = (); @@ -273,12 +276,12 @@ sub process_nlp { # to (words indicating target or destination) $format =~ s/\{to\}/(to|into)/g; - &SimBot::debug(5, "nlp: using format: $format\n"); + &debug(5, "nlp: using format: $format\n"); # Push any format matches onto an array which we'll pass to # the plugin's function. if ($text =~ /\b($format)\b/i) { - &SimBot::debug(5, "nlp: param found: $1\n"); + &debug(5, "nlp: param found: $1\n"); push(@params, $1); } } Index: recap.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/recap.pl,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -p -r1.23 -r1.24 --- recap.pl 26 Aug 2005 07:45:38 -0000 1.23 +++ recap.pl 10 Nov 2005 13:02:15 -0000 1.24 @@ -20,6 +20,9 @@ package SimBot::plugin::recap; use strict; use warnings; +# Use the SimBot Util perl module +use SimBot::Util; + use constant MAX_BACKLOG => 30; use constant STD_BACKLOG => 10; @@ -32,14 +35,14 @@ sub send_recap { if (!defined $lines) { if (defined $departs{$nick}) { $lines = $departs{$nick}; - &SimBot::debug(4, "recap: $nick recently departed, recapping from departure point ($lines lines)...\n"); + &debug(4, "recap: $nick recently departed, recapping from departure point ($lines lines)...\n"); } else { $lines = STD_BACKLOG; - &SimBot::debug(4, "recap: $nick did not specify number of lines; using default ($lines lines)...\n"); + &debug(4, "recap: $nick did not specify number of lines; using default ($lines lines)...\n"); } } - &SimBot::debug(3, "recap: Got a request from $nick for $lines lines. The backlog is " . ($#backlog + 1) . " lines.\n"); + &debug(3, "recap: Got a request from $nick for $lines lines. The backlog is " . ($#backlog + 1) . " lines.\n"); if (defined $lines && $lines =~ /^[^0-9]+$/) { &SimBot::send_message($channel, "Try using numbers. I can't count to $lines!"); } elsif ($#backlog + 1 < 1) { @@ -66,7 +69,7 @@ sub record_recap { my ($sec, $min, $hour) = localtime(time); foreach my $departed (keys %departs) { if ($departs{$departed} == MAX_BACKLOG) { - &SimBot::debug(4, "recap: $departed is no longer recently departed.\n"); + &debug(4, "recap: $departed is no longer recently departed.\n"); delete $departs{$departed}; } else { $departs{$departed}++; @@ -103,7 +106,7 @@ sub record_recap { while ($#backlog > MAX_BACKLOG) { shift(@backlog); } - &SimBot::debug(4, "recap: Recorded a line. Backlog is " . ($#backlog + 1) . " lines.\n"); + &debug(4, "recap: Recorded a line. Backlog is " . ($#backlog + 1) . " lines.\n"); } sub nick_change { @@ -119,7 +122,7 @@ sub recap_page { my $template = &$get_template('base'); $template->param( title => 'Recent Chatter', - content => &SimBot::htmlize(join("\n", @backlog)), + content => &htmlize(join("\n", @backlog)), ); $response->content($template->output()); return 200; Index: rss.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/rss.pl,v retrieving revision 1.69 retrieving revision 1.70 diff -u -d -p -r1.69 -r1.70 --- rss.pl 14 Oct 2005 01:56:20 -0000 1.69 +++ rss.pl 10 Nov 2005 13:02:15 -0000 1.70 @@ -39,6 +39,9 @@ package SimBot::plugin::rss; use strict; use warnings; +# Use the SimBot Util perl module +use SimBot::Util; + use XML::RSS; use HTML::Entities; use POE; @@ -55,10 +58,10 @@ use vars qw( %mostRecentPost $session $d $insert_headline_query $update_headline_query $update_feed_title_query $done_initial_update); -use constant CHANNEL => &SimBot::option('network', 'channel'); -use constant FEED_TITLE_STYLE => &SimBot::option('plugin.rss','title_style'); -use constant EXPIRE => (&SimBot::option('plugin.rss', 'expire') ? - &SimBot::option('plugin.rss', 'expire') : 1500); +use constant CHANNEL => &option('network', 'channel'); +use constant FEED_TITLE_STYLE => &option('plugin.rss','title_style'); +use constant EXPIRE => (&option('plugin.rss', 'expire') ? + &option('plugin.rss', 'expire') : 1500); ### messup_rss # This runs when simbot loads. We need to make sure we know the most @@ -139,18 +142,18 @@ EOT ); foreach my $cur_feed - (split(/,/, &SimBot::option('plugin.rss', 'announce'))) { + (split(/,/, &option('plugin.rss', 'announce'))) { $announce_feed{$cur_feed} = 1; } foreach my $cur_feed - (&SimBot::options_in_section('plugin.rss.feeds')) { + (&options_in_section('plugin.rss.feeds')) { $feeds{$cur_feed}=1; $get_feed_info_query->execute($cur_feed); if(my $id = ($get_feed_info_query->fetchrow_array)[0]) { # feed is already in the table, let's update it $update_feed_query->execute( - &SimBot::option('plugin.rss.feeds', $cur_feed), + &option('plugin.rss.feeds', $cur_feed), (defined $announce_feed{$cur_feed} ? 1 : 0), $id ); @@ -158,7 +161,7 @@ EOT # we need to add the feed $insert_feed_query->execute( $cur_feed, - &SimBot::option('plugin.rss.feeds', $cur_feed), + &option('plugin.rss.feeds', $cur_feed), (defined $announce_feed{$cur_feed} ? 1 : 0) ); } @@ -181,7 +184,7 @@ EOT POE::Component::Client::HTTP->spawn ( Alias => 'ua', Timeout => 120, - Agent => SimBot::PROJECT . "/" . SimBot::VERSION, + Agent => PROJECT . "/" . VERSION, FollowRedirects => 2, ); @@ -219,7 +222,7 @@ sub do_rss { my $kernel = $_[KERNEL]; my (@newPosts, $title, $request, $file); my $rss = new XML::RSS; - &SimBot::debug(3, "rss: Updating cache...\n"); + &debug(3, "rss: Updating cache...\n"); $get_all_feeds_info_query->execute; while(my ($id, undef, $key, $last_update, $url, $announce) @@ -266,14 +269,14 @@ sub got_response { my (undef, $feed_name, $key, $last_update, $feed_url, $announce) = $get_feed_by_id_query->fetchrow_array; - &SimBot::debug((($response->code >= 400) ? 1 : 4), + &debug((($response->code >= 400) ? 1 : 4), "rss: fetching feed for $key: " . $response->status_line . "\n"); if($response->code == RC_GONE) { # Server is telling us the file is gone. - &SimBot::debug(1, + &debug(1, "rss: *** FEED $key IS NO LONGER AVAILABLE\n" . " *** Removing $key from cache\n" . " *** Please remove $key from your config file\n"); @@ -302,7 +305,7 @@ sub got_response { uri => 'http://rssnamespace.org/feedburner/ext/1.0', ); if (!eval { $rss->parse($response->decoded_content); }) { - &SimBot::debug(1, "rss: Parse error in $key: $@"); + &debug(1, "rss: Parse error in $key: $@"); return; } $feed_name = $rss->{'channel'}->{'title'}; @@ -384,7 +387,7 @@ sub latest_headlines { my ($item, $title, $link); my $rss = new XML::RSS; - &SimBot::debug(3, "rss: Got request from $nick" . + &debug(3, "rss: Got request from $nick" . (defined $feed ? " for $feed" : "") . "...\n"); $get_feed_info_query->execute($feed); @@ -395,7 +398,7 @@ sub latest_headlines { # is the cache up to date? if(!defined $last_update || $last_update > time - EXPIRE) { # cache is stale or missing - &SimBot::debug(4, "rss: $feed is old or missing.\n"); + &debug(4, "rss: $feed is old or missing.\n"); my $request = HTTP::Request->new(GET => $url); $request->header('Accept-Encoding' => 'gzip, deflate'); $request->if_modified_since($last_update); @@ -403,13 +406,13 @@ sub latest_headlines { $kernel->post('ua' => 'request', 'got_response', $request, "$id!!$nick"); } else { - &SimBot::debug(4, + &debug(4, "rss: $feed is up to date; Displaying.\n"); $kernel->post($session => 'announce_top', $id, $nick, $channel); } } else { - &SimBot::debug(4, "rss: No feed matched request.\n"); + &debug(4, "rss: No feed matched request.\n"); my $message = "$nick: " . ($feed ? "I have no feed $feed." : "What feed do you want latest posts from?") @@ -458,7 +461,7 @@ sub announce_top { } if(@posts) { &SimBot::send_message(CHANNEL, - &SimBot::parse_style("$nick: Here are the latest posts to " + &parse_style("$nick: Here are the latest posts to " . &colorize_feed($feed_name) . ':')); foreach(@posts) { &SimBot::send_message(CHANNEL, $_); Index: services.chanserv.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/services.chanserv.pl,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -p -r1.12 -r1.13 --- services.chanserv.pl 26 Jul 2005 02:12:17 -0000 1.12 +++ services.chanserv.pl 10 Nov 2005 13:02:15 -0000 1.13 @@ -29,6 +29,9 @@ package SimBot::plugin::services::chanse use warnings; use strict; +# Use the SimBot Util perl module +use SimBot::Util; + # Start with the assumption Services are online, we are not locked out, and # we are not logged in, and we are not shut up. our $services_online = 0; @@ -40,21 +43,21 @@ our $shut_up = 0; # password, since logging in would be tricky, at best, without them. sub services_login { my $kernel = $_[0]; - my $pass = &SimBot::option('services', 'pass'); + my $pass = &option('services', 'pass'); if ($pass) { - &SimBot::debug(3, "Logging into services...\n"); + &debug(3, "Logging into services...\n"); $kernel->post(bot => sl => "nickserv identify $pass"); } } sub registration_check { my ($kernel, undef, undef, $newnick) = @_; - my $want = &SimBot::option('global', 'nickname'); + my $want = &option('global', 'nickname'); my $me = $SimBot::chosen_nick; if ($me eq $newnick && $me eq $want) { - &SimBot::debug(3, "Checking nickname availability...\n"); + &debug(3, "Checking nickname availability...\n"); $kernel->post(bot => sl => "nickserv info"); } } @@ -63,23 +66,23 @@ sub registration_check { # something. Here, we handle different possible cases. sub check_response { my ($kernel, $nick, undef, $text) = @_; - my $pass = &SimBot::option('services', 'pass'); + my $pass = &option('services', 'pass'); my $me = $SimBot::chosen_nick; - my $want = &SimBot::option('global', 'nickname'); - my $chan = &SimBot::option('network', 'channel'); + my $want = &option('global', 'nickname'); + my $chan = &option('network', 'channel'); if (lc($nick) eq lc("NickServ")) { $services_online = 1; if ($text =~ /is( not|n\'t) registered/i) { # Try to register!! if ($me eq $want) { - &SimBot::debug(3, "Nickname $me is not registered; trying to register it now...\n"); + &debug(3, "Nickname $me is not registered; trying to register it now...\n"); $kernel->post(bot => sl => "nickserv register $pass"); } } elsif ($text =~ /Nickname: ([^\s]+)/i) { - &SimBot::debug(4, "Nickname $1 is already registered; waiting for nickserv to ask for us to identify...\n"); + &debug(4, "Nickname $1 is already registered; waiting for nickserv to ask for us to identify...\n"); } elsif ($text =~ /Your nickname is now registered/i) { - &SimBot::debug(3, "Nickname $me registered successfully.\n"); + &debug(3, "Nickname $me registered successfully.\n"); $logged_in = 1; if ($locked_out) { &request_unban($kernel, undef, $chan); @@ -89,15 +92,15 @@ sub check_response { } } elsif ($text =~ /Password incorrect/i) { if ($logged_in == 0) { - &SimBot::debug(1, "Services reports login failure.\n"); + &debug(1, "Services reports login failure.\n"); } else { - &SimBot::debug(1, "Services command failed: Incorrect password.\n"); + &debug(1, "Services command failed: Incorrect password.\n"); } } elsif ($text =~ /This nickname is owned by someone else/i) { $logged_in = 0; &services_login($kernel); } elsif ($text =~ /you are now recognized/i) { - &SimBot::debug(3, "Services reports successful login.\n"); + &debug(3, "Services reports successful login.\n"); $logged_in = 1; if ($locked_out) { &request_unban($kernel, undef, $chan); @@ -106,14 +109,14 @@ sub check_response { &request_voice($kernel, undef, $chan); } } elsif ($text =~ /You have already identified/i) { - &SimBot::debug(2, "Services reports already logged in.\n"); + &debug(2, "Services reports already logged in.\n"); $logged_in = 1; } elsif ($text =~ /Access denied/i) { - &SimBot::debug(2, "Services reports not yet logged in.\n"); + &debug(2, "Services reports not yet logged in.\n"); $logged_in = 0; &services_login($kernel); } elsif ($text =~ m/Your nickname is not yet authenticated/i) { - &SimBot::debug(1, "Services reports: $text"); + &debug(1, "Services reports: $text"); } } @@ -121,10 +124,10 @@ sub check_response { $services_online = 1; if ($text =~ /bans matching .* cleared on (\#.*)/i) { my $chan = $1; - &SimBot::debug(3, "Services reports successful unban command.\n"); + &debug(3, "Services reports successful unban command.\n"); $kernel->post(bot => join => $chan); } elsif ($text =~ /Password identification is required/i) { - &SimBot::debug(2, "Services reports not yet logged in.\n"); + &debug(2, "Services reports not yet logged in.\n"); $logged_in = 0; &services_login($kernel); } @@ -135,14 +138,14 @@ sub check_response { # from ChanServ. sub request_unban { my ($kernel, undef, $channel, undef, $msg) = @_; - if (&SimBot::option('services', 'pass')) { + if (&option('services', 'pass')) { $locked_out = 1; if($services_online && $logged_in) { if ($msg =~ /banned/i) { - &SimBot::debug(2, "Could not join. Asking services for unban from $channel...\n"); + &debug(2, "Could not join. Asking services for unban from $channel...\n"); $kernel->post(bot => sl => "chanserv unban $channel"); } else { # Try Invite - &SimBot::debug(2, "Could not join. Asking services for invite to $channel...\n"); + &debug(2, "Could not join. Asking services for invite to $channel...\n"); $kernel->post(bot => sl => "chanserv invite $channel"); } } elsif ($services_online) { @@ -154,10 +157,10 @@ sub request_unban { # REQUEST_VOICE: If the bot was not able to speak, request a voice from ChanServ. sub request_voice { my ($kernel, undef, $channel) = @_; - if (&SimBot::option('services', 'pass')) { + if (&option('services', 'pass')) { $shut_up = 1; if($services_online && $logged_in) { - &SimBot::debug(2, "Could not speak. Asking for voice on $channel...\n"); + &debug(2, "Could not speak. Asking for voice on $channel...\n"); $kernel->post(bot => sl => "chanserv voice $channel"); $shut_up = 0; } elsif ($services_online) { @@ -180,8 +183,8 @@ sub process_notify { my ($kernel, undef, undef, @nicks) = @_; my $found = 0; my $me = $SimBot::chosen_nick; - my $want = &SimBot::option('global', 'nickname'); - my $pass = &SimBot::option('services', 'pass'); + my $want = &option('global', 'nickname'); + my $pass = &option('services', 'pass'); foreach(@nicks) { if($_ eq "NickServ") { @@ -196,7 +199,7 @@ sub process_notify { # XXX: This should probably be delayed. ®istration_check($kernel, undef, undef, $me); } else { - &SimBot::debug(3, "Desired nickname is in use; trying ghost...\n"); + &debug(3, "Desired nickname is in use; trying ghost...\n"); $kernel->post(bot => sl => "nickserv ghost $want $pass"); } } @@ -206,7 +209,7 @@ sub process_notify { # KICK_USER: Kicks a user through ChanServ. sub kick_user { my ($kernel, $channel, $user, $message) = @_; - &SimBot::debug(3, "Asking Channel Service to kick $user from $channel ($message)...\n"); + &debug(3, "Asking Channel Service to kick $user from $channel ($message)...\n"); $kernel->post(bot => sl => "chanserv kick $channel $user $message"); } @@ -214,7 +217,7 @@ sub kick_user { sub ban_user { my ($kernel, $channel, $user, $time, $message) = @_; my $hours = int($time / 3600); - &SimBot::debug(3, "Asking Channel Service to ban $user (" . + &debug(3, "Asking Channel Service to ban $user (" . &SimBot::hostmask($user) . ") from $channel ($message)...\n"); $kernel->post(bot => sl => "chanserv ban $channel " . &SimBot::hostmask($user) . "$message"); @@ -225,7 +228,7 @@ sub ban_user { # UNBAN_USER: Unbans a user through ChanServ. #sub unban_user { # my (undef, $channel, $user, $message) = @_; -# &SimBot::debug(3, "Asking Channel Service to unban $user (" . +# &debug(3, "Asking Channel Service to unban $user (" . # &SimBot::hostmask($user) . # ") from $channel...\n"); # &SimBot::send_message("ChanServ", "unban $channel " . &SimBot::hostmask($user)); Index: services.undernet.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/services.undernet.pl,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -p -r1.12 -r1.13 --- services.undernet.pl 13 Apr 2005 00:06:52 -0000 1.12 +++ services.undernet.pl 10 Nov 2005 13:02:15 -0000 1.13 @@ -20,6 +20,9 @@ package SimBot::plugin::services::undern use warnings; use strict; +# Use the SimBot Util perl module +use SimBot::Util; + # Start with the assumption X is online, we are not locked out, and # we are not logged in, and we are not shut up. our $x_online = 1; @@ -32,15 +35,15 @@ our $shut_up = 0; # We also set the +x mode to mask our hostname for some added security. sub services_login { my ($kernel, undef, $nick) = @_; - my $user = &SimBot::option('services', 'user'); - my $pass = &SimBot::option('services', 'pass'); + my $user = &option('services', 'user'); + my $pass = &option('services', 'pass'); if (defined $nick) { - &SimBot::debug(3, "Setting masked user mode...\n"); + &debug(3, "Setting masked user mode...\n"); $kernel->post(bot => mode => $nick, "+x"); } if ($pass && $user) { - &SimBot::debug(3, "Logging into Channel Service as $user...\n"); + &debug(3, "Logging into Channel Service as $user...\n"); &SimBot::send_message("x\@channels.undernet.org", "login $user $pass"); } } @@ -51,30 +54,30 @@ sub check_response { my ($kernel, $nick, undef, $text) = @_; if ($nick eq "X") { if ($text =~ /AUTHENTICATION SUCCESSFUL as /) { - &SimBot::debug(3, "Channel Service reports successful login.\n"); + &debug(3, "Channel Service reports successful login.\n"); $logged_in = 1; $x_online = 1; if ($locked_out) { - &request_invite($kernel, undef, &SimBot::option('network', 'channel')); + &request_invite($kernel, undef, &option('network', 'channel')); } if ($shut_up) { - &request_voice($kernel, undef, &SimBot::option('network', 'channel')); + &request_voice($kernel, undef, &option('network', 'channel')); } } elsif ($text =~ /AUTHENTICATION FAILED as /) { - &SimBot::debug(2, "Channel Service reports login failure.\n"); + &debug(2, "Channel Service reports login failure.\n"); $logged_in = 0; $x_online = 1; } elsif ($text =~ /Sorry, You are already authenticated as /) { - &SimBot::debug(2, "Channel Service reports already logged in.\n"); + &debug(2, "Channel Service reports already logged in.\n"); $logged_in = 1; $x_online = 1; } elsif ($text =~ /Sorry, You must be logged in to /) { - &SimBot::debug(2, "Channel Service reports not yet logged in.\n"); + &debug(2, "Channel Service reports not yet logged in.\n"); $logged_in = 0; $x_online = 1; &services_login($kernel); } else { - &SimBot::debug(4, "Channel Service message: $text\n"); + &debug(4, "Channel Service message: $text\n"); } } } @@ -83,10 +86,10 @@ sub check_response { # from X. sub request_invite { my ($kernel, undef, $channel) = @_; - if (&SimBot::option('services', 'pass')) { + if (&option('services', 'pass')) { $locked_out = 1; if($x_online && $logged_in) { - &SimBot::debug(3, "Asking Channel Service for invitation to $channel...\n"); + &debug(3, "Asking Channel Service for invitation to $channel...\n"); &SimBot::send_message("x", "invite $channel"); } elsif ($x_online) { &services_login($kernel); @@ -97,10 +100,10 @@ sub request_invite { # REQUEST_VOICE: If the bot was not able to speak, request a voice from X. sub request_voice { my ($kernel, undef, $channel) = @_; - if (&SimBot::option('services', 'pass')) { + if (&option('services', 'pass')) { $shut_up = 1; if($x_online && $logged_in) { - &SimBot::debug(2, "Could not speak. Asking for voice on $channel...\n"); + &debug(2, "Could not speak. Asking for voice on $channel...\n"); &SimBot::send_message("x", "voice $channel"); $shut_up = 0; } elsif ($x_online) { @@ -135,7 +138,7 @@ sub process_notify { # KICK_USER: Kicks a user through Channel Service. sub kick_user { my (undef, $channel, $user, $message) = @_; - &SimBot::debug(3, "Asking Channel Service to kick $user from $channel ($message)...\n"); + &debug(3, "Asking Channel Service to kick $user from $channel ($message)...\n"); &SimBot::send_message("x", "kick $channel $user $message"); } @@ -143,7 +146,7 @@ sub kick_user { sub ban_user { my (undef, $channel, $user, $time, $message) = @_; my $hours = int($time / 3600); - &SimBot::debug(3, "Asking Channel Service to ban $user (" . + &debug(3, "Asking Channel Service to ban $user (" . &SimBot::hostmask($user) . ") from $channel ($message)...\n"); &SimBot::send_message("x", "ban $channel " . &SimBot::hostmask($user) . " $hours 75 $message"); @@ -152,7 +155,7 @@ sub ban_user { # UNBAN_USER: Unbans a user through Channel Service. sub unban_user { my (undef, $channel, $user, $message) = @_; - &SimBot::debug(3, "Asking Channel Service to unban $user (" . + &debug(3, "Asking Channel Service to unban $user (" . &SimBot::hostmask($user) . ") from $channel...\n"); &SimBot::send_message("x", "unban $channel " . &SimBot::hostmask($user)); Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.72 retrieving revision 1.73 diff -u -d -p -r1.72 -r1.73 --- sqlite-logger.pl 7 Sep 2005 04:20:50 -0000 1.72 +++ sqlite-logger.pl 10 Nov 2005 13:02:15 -0000 1.73 @@ -30,6 +30,10 @@ package SimBot::plugin::sqlite::logger; use warnings; use strict; + +# Use the SimBot Util perl module +use SimBot::Util; + use Data::Dumper; use Time::Local; @@ -71,7 +75,7 @@ sub messup_sqlite_logger { { RaiseError => 1, AutoCommit => 0 } ) or die; - &SimBot::debug( 3, + &debug( 3, 'sqlite: Using SQLite version ' . $dbh->{'sqlite_version'} . "\n" ); # let's create our table. If this fails, we don't care. @@ -185,7 +189,7 @@ sub get_nickchan_name { sub log_nick_change { my ( undef, undef, $nick, $newnick ) = @_; my $channel_id = - &get_nickchan_id( &SimBot::option( 'network', 'channel' ), 0 ); + &get_nickchan_id( &option( 'network', 'channel' ), 0 ); my $source_nick_id = &get_nickchan_id( $nick, 1 ); my $target_nick_id = &get_nickchan_id( $newnick, 1 ); @@ -212,7 +216,7 @@ sub set_seen { # First, we need to identify things my $channel_id = - &get_nickchan_id( &SimBot::option( 'network', 'channel' ), 1 ); + &get_nickchan_id( &option( 'network', 'channel' ), 1 ); my $source_nick_id = &get_nickchan_id( $nick, 1 ); my $target_nick_id; @@ -293,7 +297,7 @@ sub do_seen { } else { $seen_nick = shift(@args); - &SimBot::debug( 3, + &debug( 3, "sqlite-logger: Seen request by $nick for $seen_nick\n" ); if ( $seen_nick =~ m/^\*$/ ) { @@ -377,7 +381,7 @@ sub do_seen { return; } $seen_query->execute( - &get_nickchan_id( &SimBot::option( 'network', 'channel' ) ) ); + &get_nickchan_id( &option( 'network', 'channel' ) ) ); my $row; my $last_id; my @responses; @@ -446,7 +450,7 @@ sub do_recap { . ' AND id <= ?' ); my $channel_id = - &get_nickchan_id( &SimBot::option( 'network', 'channel' ) ); + &get_nickchan_id( &option( 'network', 'channel' ) ); $start_query->execute( $channel_id, $nick_id ); my $start_row; @@ -514,7 +518,7 @@ sub access_log { } elsif ( $query =~ m/^stats/ ) { my $statnick = $args[0]; my $chan_id = - &get_nickchan_id( &SimBot::option( 'network', 'channel' ) ); + &get_nickchan_id( &option( 'network', 'channel' ) ); $nick_id = &get_nickchan_id($nick); @@ -828,11 +832,11 @@ sub update_nick_context { sub score_word { my $word = $_[1]; if ( get_nickchan_id($word) ) { - &SimBot::debug( 4, "${word}:+1000(sqlite-logger) ", - SimBot::DEBUG_NO_PREFIX ); + &debug( 4, "${word}:+1000(sqlite-logger) ", + DEBUG_NO_PREFIX ); return 1000; } - &SimBot::debug( 5, "${word}:+0(sqlite-logger) ", SimBot::DEBUG_NO_PREFIX ); + &debug( 5, "${word}:+0(sqlite-logger) ", DEBUG_NO_PREFIX ); return 0; } @@ -895,7 +899,7 @@ sub web_log { my $channel_id = ( defined $query->{'channel_id'} ? $query->{'channel_id'} - : &get_nickchan_id( &SimBot::option( 'network', 'channel' ) ) + : &get_nickchan_id( &option( 'network', 'channel' ) ) ); if ( defined $query->{'smo'} ) { $start_month = $query->{'smo'}; } @@ -969,7 +973,7 @@ sub web_stats { my $channel_id = ( defined $query->{'channel_id'} ? $query->{'channel_id'} - : &get_nickchan_id( &SimBot::option( 'network', 'channel' ) ) + : &get_nickchan_id( &option( 'network', 'channel' ) ) ); @@ -1146,7 +1150,7 @@ sub web_stats { my $channel_id = ( defined $query->{'channel_id'} ? $query->{'channel_id'} - : &get_nickchan_id( &SimBot::option( 'network', 'channel' ) ) + : &get_nickchan_id( &option( 'network', 'channel' ) ) ); # Get the numbers for the graph at the top @@ -1305,7 +1309,7 @@ sub linkify { if ( $url =~ m{^(\S+)@(\S+)\.(\S+)$} ) { # probably an email address - $curWord = &SimBot::html_mask_email($url); + $curWord = &html_mask_email($url); next; } Index: time.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/time.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- time.pl 9 May 2005 02:02:36 -0000 1.1 +++ time.pl 10 Nov 2005 13:02:15 -0000 1.2 @@ -30,6 +30,9 @@ package SimBot::plugin::time; use warnings; use strict; +# Use the SimBot Util perl module +use SimBot::Util; + use DateTime; use DateTime::TimeZone; @@ -47,7 +50,7 @@ sub do_time { } if(!@zones) { - if(my $zonelist = &SimBot::option('plugin.time', 'default_zones')) { + if(my $zonelist = &option('plugin.time', 'default_zones')) { @zones = split(/,/, $zonelist); } else { @zones = ('UTC'); @@ -68,4 +71,4 @@ sub do_time { 'Gives you the current time in a selection of time zones. <zones>: Display these timezones. Use four digit offsets (+0400 for example) or <continent>/<city> (America/New_York) or US/<zone> (US/Eastern)', event_plugin_call => \&do_time, - ); \ No newline at end of file + ); Index: tinyurl.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/tinyurl.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -p -r1.9 -r1.10 --- tinyurl.pl 18 Jul 2005 12:56:36 -0000 1.9 +++ tinyurl.pl 10 Nov 2005 13:02:15 -0000 1.10 @@ -37,6 +37,9 @@ package SimBot::plugin::tinyurl; use warnings; use strict; +# Use the SimBot Util perl module +use SimBot::Util; + use vars qw( @match_rules %urlcache ); use LWP::UserAgent; @@ -108,15 +111,15 @@ sub handle_chat { $db_query->execute($url); my $to_url; if(($to_url) = $db_query->fetchrow_array()) { - &SimBot::debug(3, "tinyurl: Looking up ${url} (cached)\n"); + &debug(3, "tinyurl: Looking up ${url} (cached)\n"); &SimBot::send_message($channel, 'TinyURL points to ' . &shorten_url($to_url)); } else { - &SimBot::debug(3, "tinyurl: Looking up ${url}\n"); + &debug(3, "tinyurl: Looking up ${url}\n"); my $useragent = LWP::UserAgent->new(requests_redirectable => undef); - $useragent->agent(SimBot::PROJECT . '/' . SimBot::VERSION); + $useragent->agent(PROJECT . '/' . VERSION); $useragent->timeout(5); my $request = HTTP::Request->new(GET => $url); my $response = $useragent->request($request); @@ -127,7 +130,7 @@ sub handle_chat { &SimBot::send_message($channel, 'TinyURL points to ' . &shorten_url($to_url)); } else { - &SimBot::debug(3, " failed! (no redirect)\n"); + &debug(3, " failed! (no redirect)\n"); } } else { # not a HTTP redirect, maybe a META? @@ -140,7 +143,7 @@ sub handle_chat { &SimBot::send_message($channel, 'TinyURL points to ' . &shorten_url($to_url)); } else { - &SimBot::debug(3, " failed!\n"); + &debug(3, " failed!\n"); warn $response->content; } } Index: todo.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/todo.pl,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -p -r1.28 -r1.29 --- todo.pl 4 May 2005 19:50:12 -0000 1.28 +++ todo.pl 10 Nov 2005 13:02:15 -0000 1.29 @@ -20,6 +20,9 @@ package SimBot::plugin::todo; use strict; use warnings; +# Use the SimBot Util perl module +use SimBot::Util; + our %vers = ( "1.0 Beta" => 1, "1.0 Final" => 1, @@ -29,7 +32,7 @@ our %vers = ( # PRINT_TODO: Prints todo list privately to the user. sub print_todo { my ($kernel, $nick) = @_; - &SimBot::debug(3, "todo: Received request from " . $nick . ".\n"); + &debug(3, "todo: Received request from " . $nick . ".\n"); if(open(TODO, "TODO")) { my $version = ""; Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.108 retrieving revision 1.109 diff -u -d -p -r1.108 -r1.109 --- weather.pl 25 Oct 2005 22:54:50 -0000 1.108 +++ weather.pl 10 Nov 2005 13:02:15 -0000 1.109 @@ -38,6 +38,9 @@ package SimBot::plugin::weather; use strict; use warnings; +# Use the SimBot Util perl module +use SimBot::Util; + # the new fangled XML weather reports need to be parsed! use XML::Simple; @@ -207,16 +210,16 @@ sub do_wx { my ($kernel, $nick, $location, $flags) = @_[KERNEL, ARG0, ARG1, ARG2]; - &SimBot::debug(3, 'weather: Received request from ' . $nick + &debug(3, 'weather: Received request from ' . $nick . " for $location\n"); # So, what are we doing? unless($flags & DO_CONDITIONS || $flags & DO_ALERTS || $flags & DO_FORECAST) { - &SimBot::send_message(&SimBot::option('network', 'channel'), + &SimBot::send_message(&option('network', 'channel'), "$nick: Sorry, something unexpected happened. This has been logged; please try again later."); - &SimBot::debug(1, "weather: in do_wx with nothing to do!\n"); + &debug(1, "weather: in do_wx with nothing to do!\n"); return; } @@ -268,7 +271,7 @@ sub do_wx { } elsif(!($flags & USING_DEFAULTS)) { # If we don't have enough information to do the forecast or # alerts, only complain if we aren't using the default options. - &SimBot::send_message(&SimBot::option('network', 'channel'), + &SimBot::send_message(&option('network', 'channel'), "$nick: Sorry, but I have no forecast for that location."); } } @@ -276,7 +279,7 @@ sub do_wx { if($flags & DO_CONDITIONS) { if(!defined $station || length($station) != 4) { # Whine and bail - &SimBot::send_message(&SimBot::option('network', 'channel'), + &SimBot::send_message(&option('network', 'channel'), "$nick: " . ($station ? STATION_LOOKS_WRONG : STATION_UNSPECIFIED) @@ -315,15 +318,15 @@ sub got_metar { = (split(/!/, $request_packet->[1], 3)); my $response = $response_packet->[0]; - &SimBot::debug(4, 'weather: Got weather for ' . $nick + &debug(4, 'weather: Got weather for ' . $nick . " for $station\n"); if ($response->is_error) { if ($response->code eq '404') { - &SimBot::send_message(&SimBot::option('network', 'channel'), "$nick: Sorry, there is no METAR report available matching \"$station\". " . FIND_STATION_AT); + &SimBot::send_message(&option('network', 'channel'), "$nick: Sorry, there is no METAR report available matching \"$station\". " . FIND_STATION_AT); } else { &SimBot::send_message( - &SimBot::option('network', 'channel'), + &option('network', 'channel'), "$nick: " . CANNOT_ACCESS); } return; @@ -331,19 +334,19 @@ sub got_metar { # my ($datestamp, $raw_metar) = split(/\n/, $response->content); my $raw_metar; if($response->content =~ m|no data available|) { - &SimBot::send_message(&SimBot::option('network', 'channel'), + &SimB... [truncated message content] |