simbot-commits Mailing List for SimBot (Page 4)
Status: Abandoned
Brought to you by:
kstange
This list is closed, nobody may subscribe to it.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(88) |
Jun
(11) |
Jul
(64) |
Aug
(74) |
Sep
(1) |
Oct
(4) |
Nov
(12) |
Dec
(4) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(7) |
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(3) |
Oct
(1) |
Nov
(4) |
Dec
|
| 2007 |
Jan
(5) |
Feb
(3) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Pete P. <fou...@us...> - 2005-08-17 12:29:24
|
Update of /cvsroot/simbot/simbot/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2628/templates Modified Files: channel_stats.default.tmpl Log Message: Show the channel name in the stats page title, and the time zone for the graph. (Which is always UTC currently, but that will change) Index: channel_stats.default.tmpl =================================================================== RCS file: /cvsroot/simbot/simbot/templates/channel_stats.default.tmpl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- channel_stats.default.tmpl 17 Aug 2005 01:49:18 -0000 1.1 +++ channel_stats.default.tmpl 17 Aug 2005 12:29:08 -0000 1.2 @@ -1,11 +1,11 @@ <!-- SimBot Default channel statistics template Copy to channel_stats.local.tmpl before editing --> -<h4>Activity by Hour</h4> +<h4>Activity by Hour <TMPL_VAR NAME=timezone></h4> <table id="hourgraph"> -<tr valign=bottom> +<tr valign="bottom"> <TMPL_LOOP NAME=hourloop> <td style="height: 10em;"> - <div class="hour<TMPL_VAR NAME=hour>" style="height: <TMPL_VAR NAME="percent">%; background-color: #DDD; border: thin solid black;"> </div> + <div class="hour<TMPL_VAR NAME=hour>" style="height: <TMPL_VAR NAME="percent">%; background-color: #DDD; border: thin solid black;"> </div></td> </TMPL_LOOP> </tr> <tr> @@ -18,7 +18,7 @@ <h4>Channel Members</h4> <ul id="nicklist"> <TMPL_LOOP NAME=nickloop> - <li><a href="<TMPL_VAR NAME=link ESCAPE=HTML>"><TMPL_VAR NAME=nick></a> (<TMPL_VAR NAME=line_count>)</a></li> + <li><a href="<TMPL_VAR NAME=link ESCAPE=HTML>"><TMPL_VAR NAME=nick></a> (<TMPL_VAR NAME=line_count>)</li> </TMPL_LOOP> </ul> |
|
From: Pete P. <fou...@us...> - 2005-08-17 01:50:32
|
Update of /cvsroot/simbot/simbot/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27832/tools Added Files: rebuild_irc_stats.pl Log Message: Forgot this. --- NEW FILE: rebuild_irc_stats.pl --- #!/usr/bin/perl # SimBot Statistics Rebuilder # # DESCRIPTION: # Recreates the statistics tables for SimBot. This should only be needed # when new features are added to the sqlite logger's statistics, or # when updating the database manually. # # COPYRIGHT: # Copyright (C) 2005, Pete Pearson # # This program is free software; you can redistribute and/or modify it # under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use warnings; use strict; use DBI; $|=1; # turn off output buffering on STDOUT so we can output .s occasionally # so it looks like we are doing something our $dbh = DBI->connect('dbi:SQLite:dbname=data/irclog','','', { RaiseError => 1, AutoCommit => 0 }) or die 'Could not set up SQLite DB!'; print 'Resetting the nickname stats table...'; { local $dbh->{RaiseError}; # let's not die in this block local $dbh->{PrintError}; # and let's be quiet $dbh->do('DROP TABLE nickstats'); $dbh->do(<<EOT); CREATE TABLE nick_hour_counts ( nick_id INTEGER, channel_id INTEGER, hour INTEGER, count INTEGER ); EOT } print " Done.\n"; # Now we loop through every line in the log. my $query = $dbh->prepare('SELECT time, channel_id, source_nick_id FROM chatlog'); my $update_query = $dbh->prepare( 'UPDATE nick_hour_counts' . ' SET count = count + 1' . ' WHERE nick_id = ?' . ' AND channel_id = ?' . ' AND hour = ?'); my $insert_query = $dbh->prepare( 'INSERT INTO nick_hour_counts' . ' (nick_id, channel_id, hour, count)' . ' VALUES (?, ?, ?, 1)'); $query->execute(); print "Calculating user's hourly line counts"; my $row_number = 0; while(my ($time, $channel_id, $nick_id) = $query->fetchrow_array) { my $hour = (gmtime($time))[2]; unless(int $update_query->execute($nick_id, $channel_id, $hour)) { $insert_query->execute($nick_id, $channel_id, $hour); } if(++$row_number % 800 == 0) { print '.'; } } print " Done\nCommitting..."; $dbh->commit; print " Done\n"; |
|
From: Pete P. <fou...@us...> - 2005-08-17 01:49:28
|
Update of /cvsroot/simbot/simbot/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27554/templates Added Files: channel_stats.default.tmpl Log Message: The start of channel statistics. --- NEW FILE: channel_stats.default.tmpl --- <!-- SimBot Default channel statistics template Copy to channel_stats.local.tmpl before editing --> <h4>Activity by Hour</h4> <table id="hourgraph"> <tr valign=bottom> <TMPL_LOOP NAME=hourloop> <td style="height: 10em;"> <div class="hour<TMPL_VAR NAME=hour>" style="height: <TMPL_VAR NAME="percent">%; background-color: #DDD; border: thin solid black;"> </div> </TMPL_LOOP> </tr> <tr> <td>00</td><td>01</td><td>02</td><td>03</td><td>04</td><td>05</td><td>06</td> <td>07</td><td>08</td><td>09</td><td>10</td><td>11</td><td>12</td> <td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td> <td>20</td><td>21</td><td>22</td><td>23</td> </tr> </table> <h4>Channel Members</h4> <ul id="nicklist"> <TMPL_LOOP NAME=nickloop> <li><a href="<TMPL_VAR NAME=link ESCAPE=HTML>"><TMPL_VAR NAME=nick></a> (<TMPL_VAR NAME=line_count>)</a></li> </TMPL_LOOP> </ul> <!-- End channel_stats --> |
|
From: Pete P. <fou...@us...> - 2005-08-17 01:49:28
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27554/plugins Modified Files: sqlite-logger.pl Log Message: The start of channel statistics. Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -p -r1.59 -r1.60 --- sqlite-logger.pl 12 Aug 2005 21:09:20 -0000 1.59 +++ sqlite-logger.pl 17 Aug 2005 01:49:18 -0000 1.60 @@ -36,7 +36,7 @@ use Data::Dumper; use Time::Local; use HTML::Entities; -use vars qw( $dbh $insert_query $get_nickchan_id_query $get_nickchan_name_query $add_nickchan_id_query ); +use vars qw( $dbh $insert_query $get_nickchan_id_query $get_nickchan_name_query $add_nickchan_id_query $update_nick_hour_count_query $insert_nick_hour_count_query); use DBI; @@ -91,6 +91,16 @@ CREATE TABLE names ( name STRING, context STRING); EOT + + $dbh->do(<<EOT); +CREATE TABLE nick_hour_counts ( + nick_id INTEGER, + channel_id INTEGER, + hour INTEGER, + count INTEGER +); +EOT + $dbh->commit; } @@ -117,6 +127,18 @@ EOT $add_nickchan_id_query = $dbh->prepare( 'INSERT INTO names (name) VALUES (?)' ); + + $update_nick_hour_count_query = $dbh->prepare( + 'UPDATE nick_hour_counts' + . ' SET count = count + 1' + . ' WHERE nick_id = ?' + . ' AND channel_id = ?' + . ' AND hour = ?'); + + $insert_nick_hour_count_query = $dbh->prepare( + 'INSERT INTO nick_hour_counts' + . ' (nick_id, channel_id, hour, count)' + . ' VALUES (?, ?, ?, 1)'); } sub cleanup_sqlite_logger { @@ -212,6 +234,12 @@ sub set_seen { $insert_query->execute(time, $channel_id, $source_nick_id, $target_nick_id, $doing, $content); $insert_query->finish; + + my $hour = (gmtime(time))[2]; + + unless(int $update_nick_hour_count_query->execute($source_nick_id, $channel_id, $hour)) { + $insert_nick_hour_count_query->execute($source_nick_id, $channel_id, $hour); + } $dbh->commit; } @@ -927,6 +955,75 @@ sub web_log { return 200; # OK } +sub web_stats { + my ($request, $response, $get_template) = @_; + + + my $query = &create_query_hash($request->uri); + + if(defined $query->{'nick_id'}) { + # doing stats for a nickname + } else { + # doing channel stats... + my $stats_template = &$get_template('channel_stats'); + + my $channel_id = (defined $query->{'channel_id'} + ? $query->{'channel_id'} + : &get_nickchan_id(&SimBot::option('network', 'channel'))); + + my @hour_counts = (0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0); + my $max_hour = 0; + my %nick_counts; + my $nick_stats_query = $dbh->prepare_cached( + 'SELECT nick_id, hour, count' + . ' FROM nick_hour_counts' + . ' WHERE channel_id = ?'); + + $nick_stats_query->execute($channel_id); + while(my @row = $nick_stats_query->fetchrow_array) { + $hour_counts[$row[1]] += $row[2]; + if($hour_counts[$row[1]] > $max_hour) { + $max_hour = $hour_counts[$row[1]]; + } + $nick_counts{$row[0]} += $row[2]; + } + + my @nick_list; + foreach my $cur_key (keys %nick_counts) { + my %hash; + $hash{'link'} = "/stats?nick_id=${cur_key}"; + $hash{'nick'} = &get_nickchan_name($cur_key); + $hash{'line_count'} = $nick_counts{$cur_key}; + push(@nick_list, \%hash); + } + + my @hour_list; + for (my $x=0; $x <= 23; $x++) { + my %hash; + $hash{'hour'} = $x; + $hash{'percent'} = ($hour_counts[$x] / $max_hour) * 100; + + push(@hour_list, \%hash); + } + + $stats_template->param(nickloop => \@nick_list, + hourloop => \@hour_list, + channel => &get_nickchan_name($channel_id), + ); + + my $base_template = &$get_template('base'); + $base_template->param( + content => $stats_template->output(), + title => 'Channel Statistics', + ); + + $response->content($base_template->output()); + $response->push_header('Content-Type', 'text/html'); + return 200; + } +} + sub create_query_hash { my ($query) = $_[0] =~ m/\?(\S+)$/; my %hash; @@ -1079,4 +1176,9 @@ sub linkify { $SimBot::hash_plugin_httpd_pages{'log'} = { 'title' => 'Log Viewer', 'handler' => \&web_request, -} +}; + +$SimBot::hash_plugin_httpd_pages{'stats'} = { + 'title' => 'Statistics', + 'handler' => \&web_stats, +}; \ No newline at end of file |
|
From: Pete P. <fou...@us...> - 2005-08-16 17:19:07
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9627 Modified Files: info.pl Log Message: OCD, perltidy, and disabling that 'if we think we know what the user is asking, answer even if not addressed' misfeature. Index: info.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/info.pl,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -p -r1.43 -r1.44 --- info.pl 6 May 2005 21:23:53 -0000 1.43 +++ info.pl 16 Aug 2005 17:18:56 -0000 1.44 @@ -15,12 +15,12 @@ # This program is free software; you can redistribute and/or modify it # under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -43,8 +43,7 @@ use strict; # Let's declare our globals. use vars qw( %info ); - -use constant CMD_PREFIX => SimBot::option('global', 'command_prefix'); +use constant CMD_PREFIX => SimBot::option( 'global', 'command_prefix' ); # These constants define the phrases simbot will use when responding # to queries. use constant I_DONT_KNOW => ( @@ -62,12 +61,10 @@ use constant OK_LEARNED => ( use constant OK_FORGOTTEN => ( '$nick: What were we talking about again?', - '$nick: Information has been nullified! Have a nice day.', - '$nick: Done. Wouldn\'t it be cool if %uline%you%uline% could forget on demand?', -); -use constant CANT_FORGET => ( - '$nick: I don\'t know anything about $key.' + '$nick: Information has been nullified! Have a nice day.', +'$nick: Done. Wouldn\'t it be cool if %uline%you%uline% could forget on demand?', ); +use constant CANT_FORGET => ('$nick: I don\'t know anything about $key.'); use constant QUERY_RESPONSE => ( '$nick: I have been told that $key $isare $factoid.', @@ -80,23 +77,20 @@ use constant ALREADY_WAS => ( '$nick: You\'re telling me stuff I already know!', ); -use constant BUT_X_IS_Y => ( - '$nick: I thought $key $isare $factoid.', -); +use constant BUT_X_IS_Y => ( '$nick: I thought $key $isare $factoid.', ); use constant BUT_X_IS_MANY => ( - '$nick: I already know many things about $key. Try \'' - . CMD_PREFIX - . 'info list $key\' to show them.', + '$nick: I already know many things about $key. Try \'' + . CMD_PREFIX + . 'info list $key\' to show them.', ); -use constant X_IS_X => ( - '$nick: Wouldn\'t $key $isare $factoid be a truism?', -); +use constant X_IS_X => + ( '$nick: Wouldn\'t $key $isare $factoid be a truism?', ); use constant X_IS_NOT_X => ( - '$nick: I don\'t know what reality you are residing in, but in mine $key $isare $factoid doesn\'t hold.', - '$nick: Maybe in %bold%your%bold% universe $key $isare $factoid, but I beg to differ.', +'$nick: I don\'t know what reality you are residing in, but in mine $key $isare $factoid doesn\'t hold.', +'$nick: Maybe in %bold%your%bold% universe $key $isare $factoid, but I beg to differ.', ); use constant I_CANNOT => ( # used to respond to requests with bad words @@ -104,13 +98,13 @@ use constant I_CANNOT => ( # used to ); # these flags are used globally. Flags <= 128 are specific to the function -use constant BEING_ADDRESSED => 256; +use constant BEING_ADDRESSED => 256; # these flags are used to tell handle_query stuff, also used when storing # factoids -use constant PREFER_DESC => 128; -use constant PREFER_LOCATION => 64; -use constant NO_RECURSE => 32; +use constant PREFER_DESC => 128; +use constant PREFER_LOCATION => 64; +use constant NO_RECURSE => 32; # => 16; # => 8; # => 4; @@ -118,13 +112,13 @@ use constant NO_RECURSE => 32; # => 1; # These flags are for factoids -use constant FACT_ARE => 128; -use constant FACT_SEE_OTHER => 64; -use constant FACT_URL => 32; -use constant FACT_LOCKED => 16; - +use constant FACT_ARE => 128; +use constant FACT_SEE_OTHER => 64; +use constant FACT_URL => 32; +use constant FACT_LOCKED => 16; + sub messup_info { - dbmopen(%info, 'data/info', 0664); + dbmopen( %info, 'data/info', 0664 ); } sub cleanup_info { @@ -144,148 +138,154 @@ sub cleanup_info { # Returns: # nothing sub handle_chat { - my(undef, $nick, $channel, undef, $content) = @_; - my($person_being_referenced, $being_addressed, $is_query); - - my $prefix = CMD_PREFIX; - if($content =~ s/^${prefix}info +//o) { + my ( undef, $nick, $channel, undef, $content ) = @_; + my ( $person_being_referenced, $being_addressed, $is_query ); + + my $prefix = CMD_PREFIX; + if ( $content =~ s/^${prefix}info +//o ) { $being_addressed = 1; } - + # Is someone being referenced? - if($content =~ s{, (\S*)[.\!\?]?$}{}) { # whatever, JohnDoe + if ( $content =~ s{, (\S*)[.\!\?]?$}{} ) { # whatever, JohnDoe $person_being_referenced = $1; } - if($content =~ s{^(\S*)[:,] }{}) { # JohnDoe: whatever + if ( $content =~ s{^(\S*)[:,] }{} ) { # JohnDoe: whatever $person_being_referenced = $1; } - if($being_addressed) { - $person_being_referenced = &SimBot::option('global', 'nickname'); -# } elsif($person_being_addressed =~ m/$SimBot::nickname/g) { -# $being_addressed = 1; + if ($being_addressed) { + $person_being_referenced = &SimBot::option( 'global', 'nickname' ); } - - - if($SimBot::snooze && !$being_addressed) { + + if ( $SimBot::snooze && !$being_addressed ) { # SimBot's in snooze mode, and shouldn't learn and should avoid # talking. Since we aren't being addressed, let's remain quiet return; } - + # Let's expand all the pronouns in the chat so we can learn something # useful. Also, try to expand any lazy URLs. - $content = &munge_pronouns($content, $nick, $person_being_referenced); + $content = &munge_pronouns( $content, $nick, $person_being_referenced ); $content = &normalize_urls($content); - - if($being_addressed && $content =~ m{^forget ([\'\-\w\s]+)}i) { #' - # someone wants us to forget - - my($forgotten, $key) = (0, lc($1)); - if($info{$key}) { + + if ( $being_addressed && $content =~ m{^forget ([\'\-\w\s]+)}i ) { #' + # someone wants us to forget + + my ( $forgotten, $key ) = ( 0, lc($1) ); + if ( $info{$key} ) { delete $info{$key}; - - &SimBot::debug(4, "info: Forgot $key (req'd by $nick)\n"); - &SimBot::send_message($channel, - &parse_message(&SimBot::pick(OK_FORGOTTEN), - $nick, $key)); + + &SimBot::debug( 4, "info: Forgot $key (req'd by $nick)\n" ); + &SimBot::send_message( $channel, + &parse_message( &SimBot::pick(OK_FORGOTTEN), $nick, $key ) ); } else { - &SimBot::send_message($channel, - &parse_message(&SimBot::pick(CANT_FORGET), - $nick, $key)); + &SimBot::send_message( $channel, + &parse_message( &SimBot::pick(CANT_FORGET), $nick, $key ) ); } - } elsif($being_addressed && $content =~ m{^list ([\'\-\w\s]+)}i) { + } elsif ( $being_addressed && $content =~ m{^list ([\'\-\w\s]+)}i ) { # someone wants to know all factoids for something ' my $key = lc($1); - - if($info{$key}) { - my @factoids = split(/\|\|/, $info{$key}); - my($factFlags, $factoid, $isare); + + if ( $info{$key} ) { + my @factoids = split( /\|\|/, $info{$key} ); + my ( $factFlags, $factoid, $isare ); my $response = "$nick: $key "; foreach (@factoids) { - ($factFlags, $factoid) = split(/\|/); + ( $factFlags, $factoid ) = split(/\|/); $isare = 'is'; - if($factFlags & FACT_ARE) { $isare = 'are'; } - elsif($factFlags & FACT_SEE_OTHER) { $isare = 'is aka'; } + if ( $factFlags & FACT_ARE ) { $isare = 'are'; } + elsif ( $factFlags & FACT_SEE_OTHER ) { $isare = 'is aka'; } $response .= "$isare $factoid, "; } - &SimBot::send_message($channel, $response); + &SimBot::send_message( $channel, $response ); } else { - &SimBot::send_message($channel, - &parse_message(&SimBot::pick(I_DONT_KNOW), - $nick, $key)); + &SimBot::send_message( $channel, + &parse_message( &SimBot::pick(I_DONT_KNOW), $nick, $key ) ); } - - } elsif($content =~ m{(where|what|who) (is|are) ([\'\-\w\s]+)}i) { + + } elsif ( $being_addressed + && $content =~ m{(where|what|who) (is|are) ([\'\-\w\s]+)}i ) + { # looks like a query ' # if $1 is where, we should try to respond with a URL # otherwise, we should try to respond with a non-URL - my $key = $3; - my $flags; - if($1 =~ m/where/i) { $flags = PREFER_LOCATION; } - else { $flags = PREFER_DESC; } - if($being_addressed) { $flags |= BEING_ADDRESSED; } - - &handle_query($key, $nick, $channel, $person_being_referenced, - $flags); - } elsif($content =~ m{where can (I|one) find ([\'\w\s]+)}i) { - # looks like a query, try to respond with a location ' - &handle_query($2, $nick, $channel, $person_being_referenced, - ($being_addressed ? BEING_ADDRESSED : 0) - | PREFER_LOCATION); - } elsif($content =~ m{([\'\-\w\s]+) is( also)?[\s\w]* (\w+://\S+)}i) { + my $key = $3; + my $flags = BEING_ADDRESSED; + if ( $1 =~ m/where/i ) { $flags |= PREFER_LOCATION; } + else { $flags |= PREFER_DESC; } + + &handle_query( $key, $nick, $channel, $person_being_referenced, + $flags ); + } elsif ( $being_addressed + && $content =~ m/where can (I|one) find ([\'\w\s]+)/i ) + { + # looks like a query, try to respond with a location + &handle_query( $2, $nick, $channel, $person_being_referenced, + BEING_ADDRESSED | PREFER_LOCATION ); + } elsif ( $content =~ m{([\'\-\w\s]+) is( also)?[\s\w]* (\w+://\S+)}i ) { # looks like a URL to me! # let's try to learn it. - my ($key, $also, $factoid) = (lc($1), $2, $3); - + my ( $key, $also, $factoid ) = ( lc($1), $2, $3 ); + my $flags = FACT_URL; - if($being_addressed) { $flags |= BEING_ADDRESSED; } - - if($also) { + if ($being_addressed) { $flags |= BEING_ADDRESSED; } + + if ($also) { # We are learning something *also* # add it to the existing key if any. If there isn't, well, # I guess 'also' didn't make sense but let's learn it anyway. - if($info{$key}) { $info{$key} .= "||$flags|$factoid"; } - else { $info{$key} = "$flags|$factoid"; } - - &report_learned($channel, $nick, $key, $factoid, $flags); - } elsif($info{$key}) { + if ( $info{$key} ) { $info{$key} .= "||$flags|$factoid"; } + else { $info{$key} = "$flags|$factoid"; } + + &report_learned( $channel, $nick, $key, $factoid, $flags ); + } elsif ( $info{$key} ) { # The key already exists, but the user didn't specify 'also' # We should whine if we are being addressed, and just ignore # it if we aren't. - if($being_addressed) { - if($info{$key} =~ m/\|\|/) { + if ($being_addressed) { + if ( $info{$key} =~ m/\|\|/ ) { # multiple keys - &SimBot::send_message($channel, - &parse_message(&SimBot::pick(BUT_X_IS_MANY), - $nick, $key)); + &SimBot::send_message( + $channel, + &parse_message( + &SimBot::pick(BUT_X_IS_MANY), + $nick, $key + ) + ); } else { - my ($keyFlags, $oldFactoid) = split(/\|/, $info{$key}, 2); + my ( $keyFlags, $oldFactoid ) = + split( /\|/, $info{$key}, 2 ); my ($isare); - - if ($keyFlags & FACT_ARE) { $isare = 'are'; } - elsif($keyFlags & FACT_SEE_OTHER) { $isare = 'is aka'; } - else { $isare = 'is'; } - - &SimBot::send_message($channel, - &parse_message(&SimBot::pick(BUT_X_IS_Y), $nick, - $key, $isare, $oldFactoid)); - } - } + + if ( $keyFlags & FACT_ARE ) { $isare = 'are'; } + elsif ( $keyFlags & FACT_SEE_OTHER ) { $isare = 'is aka'; } + else { $isare = 'is'; } + + &SimBot::send_message( + $channel, + &parse_message( + &SimBot::pick(BUT_X_IS_Y), + $nick, $key, $isare, $oldFactoid + ) + ); + } ## end else [ if ( $info{$key} =~ m/\|\|/) + } ## end if ($being_addressed) } else { $info{$key} = "$flags|$factoid"; - &report_learned($channel, $nick, $key, $factoid, $flags); + &report_learned( $channel, $nick, $key, $factoid, $flags ); } - } elsif($content =~ m{([\'\w][\'\-\w\s]*?) (is|are) ((aka|also) )?(.*)}i) { #' - no warnings; - my ($key, $isare, $akaalso, $factoid) = (lc($1), $2, $4, $5); - - my $flags=0; - if ($akaalso =~ m/aka/i) { $flags |= FACT_SEE_OTHER; } - if ($isare =~ m/are/i) { $flags |= FACT_ARE; } - if ($being_addressed) { $flags |= BEING_ADDRESSED; } - - unless($being_addressed) { - if($factoid =~ m/([\'\-\w\s]+)/) { #' + } elsif ( $content =~ m{([\'\w][\'\-\w\s]*?) (is|are) ((aka|also) )?(.*)}i ) + { #' + no warnings; + my ( $key, $isare, $akaalso, $factoid ) = ( lc($1), $2, $4, $5 ); + + my $flags = 0; + if ( $akaalso =~ m/aka/i ) { $flags |= FACT_SEE_OTHER; } + if ( $isare =~ m/are/i ) { $flags |= FACT_ARE; } + if ($being_addressed) { $flags |= BEING_ADDRESSED; } + + unless ($being_addressed) { + if ( $factoid =~ m/([\'\-\w\s]+)/ ) { $factoid = $1; } else { # We aren't being addressed, and the factoid @@ -294,69 +294,78 @@ sub handle_chat { return; } } - + # 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')) { - if($content =~ /$_/i) { - &SimBot::send_message($channel, - &parse_message(&SimBot::pick(I_CANNOT), $nick)) - if $being_addressed; + foreach ( &SimBot::option_list('filters') ) { + if ( $content =~ /$_/i ) { + &SimBot::send_message( $channel, + &parse_message( &SimBot::pick(I_CANNOT), $nick ) ) + if $being_addressed; return; } } - - if($key eq lc($factoid)) { - &SimBot::send_message($channel, - &parse_message(&SimBot::pick(X_IS_X), $nick, $key, - $isare, $factoid)) if $being_addressed; + + if ( $key eq lc($factoid) ) { + &SimBot::send_message( + $channel, + &parse_message( + &SimBot::pick(X_IS_X), + $nick, $key, $isare, $factoid + ) + ) + if $being_addressed; return; } - - if($key =~ m/(your|you're|you are)/i) { + + if ( $key =~ m/(your|you're|you are)/i ) { # key contains a pronoun we can't expand # Let's not learn it. return; } - if($akaalso =~ m/also/i) { + if ( $akaalso =~ m/also/i ) { # We are learning something *also* - if($info{$key}) { $info{$key} .= "||$flags|$factoid"; } - else { $info{$key} = "$flags|$factoid"; } - - &report_learned($channel, $nick, $key, $factoid, $flags); - } elsif($info{$key} && $being_addressed) { - if($info{$key} =~ m/\|\|/) { + if ( $info{$key} ) { $info{$key} .= "||$flags|$factoid"; } + else { $info{$key} = "$flags|$factoid"; } + + &report_learned( $channel, $nick, $key, $factoid, $flags ); + } elsif ( $info{$key} && $being_addressed ) { + if ( $info{$key} =~ m/\|\|/ ) { # multiple keys - &SimBot::send_message($channel, - &parse_message(&SimBot::pick(BUT_X_IS_MANY), - $nick, $key)); + &SimBot::send_message( $channel, + &parse_message( &SimBot::pick(BUT_X_IS_MANY), $nick, $key ) + ); } else { - my ($keyFlags, $oldFactoid) = split(/\|/, $info{$key}, 2); + my ( $keyFlags, $oldFactoid ) = split( /\|/, $info{$key}, 2 ); my ($isare); - - if ($keyFlags & FACT_ARE) { $isare = 'are'; } - elsif($keyFlags & FACT_SEE_OTHER) { $isare = 'is aka'; } - else { $isare = 'is'; } - - &SimBot::send_message($channel, - &parse_message(&SimBot::pick(BUT_X_IS_Y), $nick, - $key, $isare, $oldFactoid)); - } - } elsif(!$info{$key}) { + if ( $keyFlags & FACT_ARE ) { $isare = 'are'; } + elsif ( $keyFlags & FACT_SEE_OTHER ) { $isare = 'is aka'; } + else { $isare = 'is'; } + + &SimBot::send_message( + $channel, + &parse_message( + &SimBot::pick(BUT_X_IS_Y), + $nick, $key, $isare, $oldFactoid + ) + ); + } ## end else [ if ( $info{$key} =~ m/\|\|/) + + } elsif ( !$info{$key} ) { $info{$key} = "$flags|$factoid"; - &report_learned($channel, $nick, $key, $factoid, $flags); + &report_learned( $channel, $nick, $key, $factoid, $flags ); } - } elsif($being_addressed && $content =~ m{^([\'\-\w\s]+)$}) { + } elsif ( $being_addressed && $content =~ m{^([\'\-\w\s]+)$} ) { # KEEP THIS ELSIF LAST # Single phrase, doesn't match anything else and we are being # addressed. Let's do a query. - &handle_query($1, $nick, $channel, undef, BEING_ADDRESSED); + &handle_query( $1, $nick, $channel, undef, BEING_ADDRESSED ); } -} +} ## end sub handle_chat ### handle_query # This method takes a query and sends back to the channel the response @@ -369,66 +378,72 @@ sub handle_chat { # Returns: # nothing sub handle_query { - my ($query, $nick, $channel, $addressed, $flags) = @_; - - if($addressed && !($flags & BEING_ADDRESSED)) { + my ( $query, $nick, $channel, $addressed, $flags ) = @_; + + if ( $addressed && !( $flags & BEING_ADDRESSED ) ) { # Someone's being referenced, and it isn't us. # We should keep quiet. return; } - + $query = lc($query); - if($info{$query}) { - my @factoids = split(/\|\|/, $info{$query}); - my($factFlags, $factoid); - + if ( $info{$query} ) { + my @factoids = split( /\|\|/, $info{$query} ); + my ( $factFlags, $factoid ); + # If we are to prefer locations or descriptions, let's remove # everything else from the list. - if(($flags & PREFER_LOCATION) || ($flags & PREFER_DESC)) { - for(my $i=0;$i<=$#factoids;$i++) { - ($factFlags,$factoid) = split(/\|/, $factoids[$i], 2); + if ( ( $flags & PREFER_LOCATION ) || ( $flags & PREFER_DESC ) ) { + for ( my $i = 0; $i <= $#factoids; $i++ ) { + ( $factFlags, $factoid ) = split( /\|/, $factoids[$i], 2 ); my $isLoc = 0; - if(($factFlags & FACT_URL) - || ($factoid =~ m/^(at|on|in|near)/i)) { + if ( ( $factFlags & FACT_URL ) + || ( $factoid =~ m/^(at|on|in|near)/i ) ) + { $isLoc = 1; } - if( ($flags & PREFER_LOCATION && !$isLoc) - || ($flags & PREFER_DESC && $isLoc) ) { + if ( ( $flags & PREFER_LOCATION && !$isLoc ) + || ( $flags & PREFER_DESC && $isLoc ) ) + { # if we are preferring URLs, and the factoid isn't # or we are preferring non-URLs, and the factoid is - - splice(@factoids, $i, 1); # remove it - $i--; + + splice( @factoids, $i, 1 ); # remove it + $i--; } - } - # if we lost all of the factoids, let's get the list back - if(!@factoids) { @factoids = split(/\|\|/, $info{$query}); } - } - - ($factFlags, $factoid) = split(/\|/, &SimBot::pick(@factoids), 2); - + } ## end for ( my $i = 0; $i <= ... + # if we lost all of the factoids, let's get the list back + if ( !@factoids ) { @factoids = split( /\|\|/, $info{$query} ); } + } ## end if ( ( $flags & PREFER_LOCATION... + + ( $factFlags, $factoid ) = split( /\|/, &SimBot::pick(@factoids), 2 ); + my $isare = 'is'; - if($factFlags & FACT_ARE) { $isare = 'are'; } - - if($factFlags & FACT_SEE_OTHER - && !($flags & NO_RECURSE)) { - &handle_query($factoid, $nick, $channel, undef, - $flags | NO_RECURSE); + if ( $factFlags & FACT_ARE ) { $isare = 'are'; } + + if ( $factFlags & FACT_SEE_OTHER + && !( $flags & NO_RECURSE ) ) + { + &handle_query( $factoid, $nick, $channel, undef, + $flags | NO_RECURSE ); return; } - - if($factFlags & FACT_URL) { $factoid = "at ${factoid}"; } - - &SimBot::send_message($channel, - &parse_message(&SimBot::pick(QUERY_RESPONSE), - $nick, $query, $isare, $factoid)); - } elsif($flags & BEING_ADDRESSED) { + + if ( $factFlags & FACT_URL ) { $factoid = "at ${factoid}"; } + + &SimBot::send_message( + $channel, + &parse_message( + &SimBot::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)); + &SimBot::send_message( $channel, + &parse_message( &SimBot::pick(I_DONT_KNOW), $nick, $query ) ); } -} +} ## end sub handle_query ### report_learned # This method simply logs and reports to the channel that some fact @@ -443,20 +458,20 @@ sub handle_query { # Returns: # nothing sub report_learned { - my($channel, $nick, $key, $factoid, $flags) = @_; + my ( $channel, $nick, $key, $factoid, $flags ) = @_; my $flagTxt; - - if ($flags & FACT_ARE) { $flagTxt = '=are=>'; } - elsif($flags & FACT_SEE_OTHER) { $flagTxt = '=seeother=>'; } - else { $flagTxt = '=is=>'; } - if ($flags & FACT_URL) { $flagTxt .= ' =url='; } - - &SimBot::debug(4, "info: Learning from $nick: $key $flagTxt $factoid\n"); - &SimBot::send_message($channel, - &parse_message(&SimBot::pick(OK_LEARNED), $nick) - . " ($key $flagTxt $factoid)") - if ($flags & BEING_ADDRESSED); -} + + if ( $flags & FACT_ARE ) { $flagTxt = '=are=>'; } + elsif ( $flags & FACT_SEE_OTHER ) { $flagTxt = '=seeother=>'; } + else { $flagTxt = '=is=>'; } + if ( $flags & FACT_URL ) { $flagTxt .= ' =url='; } + + &SimBot::debug( 4, "info: Learning from $nick: $key $flagTxt $factoid\n" ); + &SimBot::send_message( $channel, + &parse_message( &SimBot::pick(OK_LEARNED), $nick ) + . " ($key $flagTxt $factoid)" ) + if ( $flags & BEING_ADDRESSED ); +} ## end sub report_learned ### parse_message # This function parses a string for certain variables, as well as for @@ -472,15 +487,15 @@ sub report_learned { # a string containing IRC color codes and completed variables # this string <strong>should not</strong> be output to a console! sub parse_message { - my ($message, $nick, $key, $isare, $factoid) = @_; - + my ( $message, $nick, $key, $isare, $factoid ) = @_; + $message = &SimBot::parse_style($message); - + $message =~ s/\$nick/$nick/g; $message =~ s/\$key/$key/g; $message =~ s/\$isare/$isare/g; $message =~ s/\$factoid/$factoid/g; - + return $message; } @@ -496,23 +511,23 @@ sub parse_message { # Returns: # a string with expanded pronouns sub munge_pronouns { - my ($content, $nick, $person_being_referenced, $thirdperson) = @_; - - $content =~ s{\bi am\b} {$nick is}ig; # I am -> $nick is - $content =~ s{\bmy\b} {${nick}'s}ig; # my -> $nick's - $content =~ s{\bmine\b} {${nick}'s}ig; # mine -> $nick's - $content =~ s{\bme\b} {$nick}ig; # me -> $nick - $content =~ s{\bam i\b} {is $nick}ig; # am I -> is $nick - if($person_being_referenced) { + my ( $content, $nick, $person_being_referenced, $thirdperson ) = @_; + + $content =~ s{\bi am\b} {$nick is}ig; # I am -> $nick is + $content =~ s{\bmy\b} {${nick}'s}ig; # my -> $nick's + $content =~ s{\bmine\b} {${nick}'s}ig; # mine -> $nick's + $content =~ s{\bme\b} {$nick}ig; # me -> $nick + $content =~ s{\bam i\b} {is $nick}ig; # am I -> is $nick + if ($person_being_referenced) { # you're, you are -> $person_being_referenced is $content =~ s/\b(you\'re|you are)/${person_being_referenced} is/ig; - #' + # your -> $person_being_referenced's - $content =~ s/\byour/${person_being_referenced}\'s/ig; #' + $content =~ s/\byour/${person_being_referenced}\'s/ig; #' } - + return $content; -} +} ## end sub munge_pronouns ### normalize_urls # This function looks through a string for things that might be URLs and @@ -523,39 +538,42 @@ sub munge_pronouns { # Returns: # a string with expanded URLs sub normalize_urls { - my @words = split(/\s+/, $_[0]); + my @words = split( /\s+/, $_[0] ); my $curWord; - + foreach $curWord (@words) { # map some common host names to protocols $curWord =~ s{^(www|web)\.} {http://$1\.}; $curWord =~ s{^ftp\.} {ftp://ftp\.}; - - if($curWord =~ m{^((http|ftp|news|nntp|mailto|aim)s?:[\w.?/]+)}) { + + if ( $curWord =~ m{^((http|ftp|news|nntp|mailto|aim)s?:[\w.?/]+)} ) { $curWord = $1; next; } - - if($curWord =~ m{/}) { - my ($host, $path) = split(m{/}, $curWord, 2); - + + if ( $curWord =~ m{/} ) { + my ( $host, $path ) = split( m{/}, $curWord, 2 ); + # does the first segment have a TLD? - if($host =~ m{\.(com|org|net|edu|gov|mil|int + if ( + $host =~ m{\.(com|org|net|edu|gov|mil|int |biz|pro|info|aero|coop|name - |museum|\w\w)$}ix) { + |museum|\w\w)$}ix + ) + { # Yup. Let's assume it's a web site... $host = 'http://' . $host; } $curWord = $host . '/' . $path; - } - } - return join(' ', @words); -} + } ## end if ( $curWord =~ m{/} ) + } ## end foreach $curWord (@words) + return join( ' ', @words ); +} ## end sub normalize_urls &SimBot::plugin_register( - plugin_id => 'info', + plugin_id => 'info', plugin_params => '(<key> [is [also] <fact>] | list <key> | forget <key>)', - plugin_help => <<EOT, + plugin_help => <<EOT, If only <key> is specified, a random associated fact will be returned. If <key> is <fact> is specified, <fact> will be stored under <key>, unless <key> already exists. Use 'is also' to add facts to existing keys. @@ -564,8 +582,8 @@ If forget <key> is specified, all associ The truthfulness of any stored facts is not guaranteed. EOT - event_plugin_call => sub {}, # Do nothing. - event_plugin_load => \&messup_info, - event_plugin_unload => \&cleanup_info, - event_channel_message => \&handle_chat, + event_plugin_call => sub { }, # Do nothing. + event_plugin_load => \&messup_info, + event_plugin_unload => \&cleanup_info, + event_channel_message => \&handle_chat, ); |
|
From: Pete P. <fou...@us...> - 2005-08-16 17:02:48
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4170 Modified Files: config.default.ini Log Message: Mumble. Index: config.default.ini =================================================================== RCS file: /cvsroot/simbot/simbot/config.default.ini,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -p -r1.30 -r1.31 --- config.default.ini 27 Jul 2005 22:20:55 -0000 1.30 +++ config.default.ini 16 Aug 2005 17:02:39 -0000 1.31 @@ -151,6 +151,7 @@ match=(^|\b)cock match=(^|\b)pen[ei]s match=(^|\b)tits match=goatse +match=goat\.cx match=tubgirl match=(^|\b)jackoff match=(^|\b)queer |
|
From: Pete P. <fou...@us...> - 2005-08-14 01:42:42
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9664/plugins Modified Files: 8ball.pl Log Message: perltidy Index: 8ball.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/8ball.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- 8ball.pl 24 Jul 2005 11:45:29 -0000 1.3 +++ 8ball.pl 14 Aug 2005 01:42:34 -0000 1.4 @@ -53,35 +53,35 @@ use constant BLANK_SAYINGS => ( # $nick will be replaced by the supplicant's nick use constant INTROS => ( q(pulls out a Magic 8 Ball and concentrates deeply on $nick's question:), - q(drops the magic 8 ball on the floor, catches it as it rolls away, and shows the answer to $nick's question:), +q(drops the magic 8 ball on the floor, catches it as it rolls away, and shows the answer to $nick's question:), q(vigorously shakes the 8-ball to find the answer to $nick's question:), -); #' - -use constant BLANK_INTROS => ( - q(pulls out a Magic 8 Ball and concentrates deeply on nothingness:), ); +use constant BLANK_INTROS => + ( q(pulls out a Magic 8 Ball and concentrates deeply on nothingness:), ); sub consult_the_8ball { - my ($kernel, $nick, $channel, undef, $question) = @_; - &SimBot::debug(3, "8ball: Consulting the Magic Eight Ball for $nick\n"); - + my ( $kernel, $nick, $channel, undef, $question ) = @_; + &SimBot::debug( 3, "8ball: Consulting the Magic Eight Ball for $nick\n" ); + my $message; - - if(defined $question) { - $message = &SimBot::pick((INTROS)) . ' ' . &SimBot::pick((SAYINGS)); + + if ( defined $question ) { + $message = &SimBot::pick( (INTROS) ) . ' ' . &SimBot::pick( (SAYINGS) ); } else { - $message = &SimBot::pick((BLANK_INTROS)) . ' ' . &SimBot::pick((BLANK_SAYINGS)); + $message = + &SimBot::pick( (BLANK_INTROS) ) . ' ' . &SimBot::pick( (BLANK_SAYINGS) ); } $message =~ s/\$nick/$nick/g; - - &SimBot::send_action($channel, $message); -} + + &SimBot::send_action( $channel, $message ); +} ## end sub consult_the_8ball # Register plugin -&SimBot::plugin_register(plugin_id => '8ball', - plugin_help => 'Consults the Magic 8 Ball. Be sure to ask a question!', - plugin_params => '<question>', - event_plugin_call => \&consult_the_8ball, - ); - \ No newline at end of file +&SimBot::plugin_register( + plugin_id => '8ball', + plugin_help => 'Consults the Magic 8 Ball. Be sure to ask a question!', + plugin_params => '<question>', + event_plugin_call => \&consult_the_8ball, +); + |
|
From: Pete P. <fou...@us...> - 2005-08-14 01:28:34
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7929 Modified Files: .cvsignore Log Message: Shut up more. Index: .cvsignore =================================================================== RCS file: /cvsroot/simbot/simbot/.cvsignore,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -p -r1.16 -r1.17 --- .cvsignore 14 Aug 2005 01:27:02 -0000 1.16 +++ .cvsignore 14 Aug 2005 01:28:26 -0000 1.17 @@ -5,3 +5,4 @@ simbot.sh *.stackdump forecast_debug .project +.settings |
|
From: Pete P. <fou...@us...> - 2005-08-14 01:27:09
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7724 Modified Files: .cvsignore Log Message: Shut up, CVS. Index: .cvsignore =================================================================== RCS file: /cvsroot/simbot/simbot/.cvsignore,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -p -r1.15 -r1.16 --- .cvsignore 6 May 2005 21:23:53 -0000 1.15 +++ .cvsignore 14 Aug 2005 01:27:02 -0000 1.16 @@ -4,3 +4,4 @@ simbot.sh .DS_Store *.stackdump forecast_debug +.project |
|
From: Pete P. <fou...@us...> - 2005-08-14 01:26:33
|
Update of /cvsroot/simbot/simbot/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7664/templates Modified Files: base.default.tmpl Log Message: As Kewlio pointed out, we have standards compliance. Index: base.default.tmpl =================================================================== RCS file: /cvsroot/simbot/simbot/templates/base.default.tmpl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- base.default.tmpl 11 Aug 2005 15:25:29 -0000 1.5 +++ base.default.tmpl 14 Aug 2005 01:26:25 -0000 1.6 @@ -12,8 +12,8 @@ <TMPL_VAR NAME=content> </div> <div id="footer"> -We probably donât have standards compliance yet, but itâs -<a href="http://validator.w3.org/check?uri=referer">worth a shot</a>.<br/> +Best viewed in a standards compliant browser. +<a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.1</a>.<br/> <a href="<TMPL_VAR ESCAPE=HTML NAME=sb_link>"><TMPL_VAR NAME=sb_version></a> </div> |
|
From: Pete P. <fou...@us...> - 2005-08-13 19:20:43
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8255/plugins Modified Files: httpd.pl Log Message: perltidy Index: httpd.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/httpd.pl,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -p -r1.19 -r1.20 --- httpd.pl 11 Aug 2005 15:25:29 -0000 1.19 +++ httpd.pl 13 Aug 2005 19:20:35 -0000 1.20 @@ -31,221 +31,231 @@ use vars qw( $kernel ); POE::Component::Server::TCP->new( Alias => 'web_server', - Port => (defined &SimBot::option('plugin.httpd', 'port') - ? &SimBot::option('plugin.httpd', 'port') - : 8000), + Port => ( + defined &SimBot::option( 'plugin.httpd', 'port' ) + ? &SimBot::option( 'plugin.httpd', 'port' ) + : 8000 + ), ClientFilter => 'POE::Filter::HTTPD', - + ClientInput => \&index_handler, ); sub index_handler { - my ($kernel, $heap, $request) = @_[KERNEL, HEAP, ARG0]; -# my ($request, $response) = @_; + my ( $kernel, $heap, $request ) = @_[ KERNEL, HEAP, ARG0 ]; - if($request->isa("HTTP::Response")) { + if ( $request->isa("HTTP::Response") ) { # We couldn't parse the client's request... shouldn't happen... # POE::Filter::HTTPD generated a response for us, isn't that kind? # Let's send it on its way... $heap->{client}->put($request); return; } - + my $response = HTTP::Response->new(200); - + my ($req_root) = $request->uri =~ m|^/([^/\?]*)|; - - &SimBot::debug(3, 'httpd: handling request for ' . $request->uri . ", req root $req_root\n"); - my $code = 500; # An error by default. - - if($req_root && defined $SimBot::hash_plugin_httpd_pages{$req_root}) { + + &SimBot::debug( 3, + 'httpd: handling request for ' + . $request->uri + . ", req root $req_root\n" ); + my $code = 500; # An error by default. + + if ( $req_root && defined $SimBot::hash_plugin_httpd_pages{$req_root} ) { my $handler = $SimBot::hash_plugin_httpd_pages{$req_root}->{'handler'}; - $code = &$handler($request, $response, \&get_template); - + $code = &$handler( $request, $response, \&get_template ); + } else { - if($req_root) { # a page was requested, but we don't have it. + if ($req_root) { # a page was requested, but we don't have it. $code = RC_NOT_FOUND; } else { # do the index page my $msg; $msg .= "<ul>\n"; - foreach my $url (keys %SimBot::hash_plugin_httpd_pages) { + foreach my $url ( keys %SimBot::hash_plugin_httpd_pages ) { my $title = $SimBot::hash_plugin_httpd_pages{$url}->{'title'}; - - if(defined $title) { + + if ( defined $title ) { $msg .= qq(<li><a href="$url">$title</a></li>\n); } } $msg .= "</ul>\n"; - + $code = RC_OK; - $response->push_header("Content-Type", "text/html"); - + $response->push_header( "Content-Type", "text/html" ); + my $template = &get_template('base'); $template->param( - title => 'Index', + title => 'Index', content => $msg, ); - $response->content($template->output()); - } - } - - if(!defined $code || int $code >= 300 || int $code < 200) { + $response->content( $template->output() ); + } ## end else [ if ($req_root) + } ## end else [ if ( $req_root && defined... + + if ( !defined $code || int $code >= 300 || int $code < 200 ) { # Plugin gave us no return value, or an error code, or an absurd number # make the error page. - if(!defined $code || $code < 200 || $code >= 600) { + if ( !defined $code || $code < 200 || $code >= 600 ) { # no code, or code absurd. $code = RC_INTERNAL_SERVER_ERROR; } my $err_template = &get_template("error.$code"); - if(!defined $err_template) { $err_template = &get_template('error.500'); } - if(!defined $err_template) { + if ( !defined $err_template ) { + $err_template = &get_template('error.500'); + } + if ( !defined $err_template ) { $response->code(RC_INTERNAL_SERVER_ERROR); - $response->content("An internal error prevented us from completing your request, and no template was available for the error message."); + $response->content( +"An internal error prevented us from completing your request, and no template was available for the error message." + ); } else { $response->code($code); - $err_template->param( - request_url => $request->uri, - ); + $err_template->param( request_url => $request->uri, ); my $base_template = &get_template('base'); $base_template->param( content => $err_template->output(), - title => "$code " . status_message($code), + title => "$code " . status_message($code), ); - $response->content($base_template->output()); + $response->content( $base_template->output() ); } - } - + } ## end if ( !defined $code ||... + $response->code($code); $heap->{client}->put($response); $kernel->yield('shutdown'); -} +} ## end sub index_handler sub get_template { my $template = $_[0]; my $file_name; - - if(-r "templates/${template}.local.tmpl") { + + if ( -r "templates/${template}.local.tmpl" ) { $file_name = "templates/${template}.local.tmpl"; - } elsif(-r "templates/${template}.default.tmpl") { + } elsif ( -r "templates/${template}.default.tmpl" ) { $file_name = "templates/${template}.default.tmpl"; } else { - &SimBot::debug(&SimBot::DEBUG_WARN, "httpd: No template $template available!\n"); + &SimBot::debug( &SimBot::DEBUG_WARN, + "httpd: No template $template available!\n" ); return; } - - my $templ_obj = HTML::Template->new( filename => $file_name, + + my $templ_obj = HTML::Template->new( + filename => $file_name, die_on_bad_params => 0, - case_sensitive => 1, + case_sensitive => 1, loop_context_vars => 1, ); $templ_obj->param( sb_version => &SimBot::PROJECT . ' ' . &SimBot::VERSION, - sb_link => &SimBot::HOME_PAGE, + sb_link => &SimBot::HOME_PAGE, ); return $templ_obj; -} +} ## end sub get_template sub admin_page { - my ($request, $response) = @_; - - if(!defined &SimBot::option('plugin.httpd', 'admin_pass')) { - &SimBot::debug(&SimBot::DEBUG_WARN, "httpd: in admin_page with no password defined!\n"); - return 500; # internal server error + my ( $request, $response ) = @_; + + if ( !defined &SimBot::option( 'plugin.httpd', 'admin_pass' ) ) { + &SimBot::debug( &SimBot::DEBUG_WARN, + "httpd: in admin_page with no password defined!\n" ); + return 500; # internal server error } - - if(!defined $request->authorization_basic) { + + if ( !defined $request->authorization_basic ) { $response->www_authenticate('Basic realm="simbot admin"'); $response->code(RC_UNAUTHORIZED); 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')) { - + my ( $user, $pass ) = $request->authorization_basic; + if ( $user ne &SimBot::option( 'plugin.httpd', 'admin_user' ) + || $pass ne &SimBot::option( 'plugin.httpd', 'admin_pass' ) ) + { + $response->www_authenticate('Basic realm="simbot admin"'); $response->code(RC_UNAUTHORIZED); return RC_UNAUTHORIZED; } my $msg; my $say; - - if($request->uri =~ m|\?restart$|) { - if(!defined $kernel) { + + if ( $request->uri =~ m|\?restart$| ) { + if ( !defined $kernel ) { warn "Trying to restart simbot without a kernel"; } - POE::Kernel->post('simbot', 'restart', "web admin"); + POE::Kernel->post( 'simbot', 'restart', "web admin" ); $response->code(RC_OK); $response->content('OK, restarting'); return RC_OK; - } elsif(($say) = $request->uri =~ m|\?say=(\S+)$|) { + } 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); - } elsif(($say) = $request->uri =~ m|\?action=(\S+)$|) { + &SimBot::debug( 3, "Speech requested by web admin\n" ); + &SimBot::send_message( &SimBot::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); + &SimBot::debug( 3, "Action requested by web admin\n" ); + &SimBot::send_action( &SimBot::option( 'network', 'channel' ), $say ); } $msg .= '<ul><li><a href="/admin?restart">Restart Simbot</a></li>'; - $msg .= '<li><form method="get" action=""><label for="say">Say: </label><input name="say"/></form></li>'; - $msg .= '<li><form method="get" action=""><label for="action">Action: </label><input name="action"/></form></li>'; + $msg .= +'<li><form method="get" action=""><label for="say">Say: </label><input name="say"/></form></li>'; + $msg .= +'<li><form method="get" action=""><label for="action">Action: </label><input name="action"/></form></li>'; $msg .= '</ul>'; $response->code(RC_OK); - + my $template = &get_template('base'); $template->param( - title => 'Admin', + title => 'Admin', content => $msg, ); - $response->content($template->output()); + $response->content( $template->output() ); return RC_OK; -} +} ## end sub admin_page sub serve_css { - my ($request, $response) = @_; - + my ( $request, $response ) = @_; + my ($filename) = $request->uri =~ m{/css/([^/]+)$}; # should be something like main.css - + $filename =~ s/\.css$//; # now is something like main - - if(!defined $filename) { return RC_FORBIDDEN; } - # (user didn't ask for anything and we're unwilling to give a list) - - if(-r "templates/css/${filename}.local.css") { + + if ( !defined $filename ) { return RC_FORBIDDEN; } + # (user didn't ask for anything and we're unwilling to give a list) + + if ( -r "templates/css/${filename}.local.css" ) { $filename = "templates/css/${filename}.local.css"; - } elsif( -r "templates/css/${filename}.default.css") { + } elsif ( -r "templates/css/${filename}.default.css" ) { $filename = "templates/css/${filename}.default.css"; } else { return RC_NOT_FOUND; } - + { local $/; - open(IN, $filename) or return RC_INTERNAL_SERVER_ERROR; + open( IN, $filename ) or return RC_INTERNAL_SERVER_ERROR; my $content = <IN>; - $response->push_header("Content-Type", "text/css"); + $response->push_header( "Content-Type", "text/css" ); $response->content($content); close IN; } return RC_OK; -} +} ## 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) - { +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 ) + { $SimBot::hash_plugin_httpd_pages{'admin'} = { - 'title' => 'SimBot Administration', + 'title' => 'SimBot Administration', 'handler' => \&admin_page, }; } @@ -253,13 +263,13 @@ sub messup_httpd { } sub cleanup_httpd { - &SimBot::debug(3, "httpd: Shutting down..."); - POE::Kernel->call('web_server', 'shutdown'); - &SimBot::debug(3, " ok\n"); + &SimBot::debug( 3, "httpd: Shutting down..." ); + POE::Kernel->call( 'web_server', 'shutdown' ); + &SimBot::debug( 3, " ok\n" ); } &SimBot::plugin_register( - plugin_id => 'httpd', - event_plugin_load => \&messup_httpd, + plugin_id => 'httpd', + event_plugin_load => \&messup_httpd, event_plugin_unload => \&cleanup_httpd, ); |
|
From: Pete P. <fou...@us...> - 2005-08-12 21:09:30
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6133/plugins Modified Files: sqlite-logger.pl Log Message: How did I forget ~ is valid in URLs? Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -p -r1.58 -r1.59 --- sqlite-logger.pl 11 Aug 2005 15:50:25 -0000 1.58 +++ sqlite-logger.pl 12 Aug 2005 21:09:20 -0000 1.59 @@ -998,7 +998,7 @@ sub linkify { . ($bgcolor != -1 ? "bgcolor$color " : '') ); - $tag .= "<span class=\"$class\">" if ($class ne ""); + $tag .= "<span class=\"$class\">" if ($class ne ''); $line =~ s/$block/$tag/; } # end while blocks $line .= "</span>" if ($tag =~ /<span/); @@ -1022,7 +1022,7 @@ sub linkify { next; } - if($url =~ m{^((http|ftp|news|nntp|irc|aim)s?:[\w.?/=\-\&\;]+)}) { + if($url =~ m{^((http|ftp|news|nntp|irc|aim)s?:[\w.?/=\-\&\~\;]+)}) { $curWord = qq($word_prefix<a href="$1">$word</a>$word_suffix); next; } |
|
From: Pete P. <fou...@us...> - 2005-08-12 01:32:57
|
Update of /cvsroot/simbot/simbot/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31979/templates Modified Files: irclog.default.tmpl Log Message: Quit messages should be shown. Index: irclog.default.tmpl =================================================================== RCS file: /cvsroot/simbot/simbot/templates/irclog.default.tmpl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- irclog.default.tmpl 10 Aug 2005 16:49:38 -0000 1.3 +++ irclog.default.tmpl 12 Aug 2005 01:32:48 -0000 1.4 @@ -18,7 +18,7 @@ <TMPL_ELSE><TMPL_IF EXPR="event eq 'PARTED'"> â <span class="nick"><TMPL_VAR NAME=source_nick></span> left. <TMPL_ELSE><TMPL_IF EXPR="event eq 'QUIT'"> - â <span class="nick"><TMPL_VAR NAME=source_nick></span> quit IRC. + â <span class="nick"><TMPL_VAR NAME=source_nick></span> quit IRC. (<TMPL_VAR NAME=content>) <TMPL_ELSE><TMPL_IF EXPR="event eq 'TOPIC'"> â´ <span class="nick"><TMPL_VAR NAME=source_nick></span> set the topic to: <TMPL_VAR NAME=content> <TMPL_ELSE><TMPL_IF EXPR="event eq 'MODE'"> |
|
From: Kevin S. <ks...@us...> - 2005-08-11 15:50:32
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25485/plugins Modified Files: sqlite-logger.pl Log Message: bgcolors need love too Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -p -r1.57 -r1.58 --- sqlite-logger.pl 11 Aug 2005 15:46:56 -0000 1.57 +++ sqlite-logger.pl 11 Aug 2005 15:50:25 -0000 1.58 @@ -966,7 +966,7 @@ sub linkify { $line =~ m/(\d{1,2})?(,(\d{1,2}))?/; if ($2) { $color = int $1 if $1; - $bgcolor = $3; + $bgcolor = int $3; $line =~ s/$1$2//; } elsif ($1) { $color = int $1; |
|
From: Pete P. <fou...@us...> - 2005-08-11 15:47:04
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24750/plugins Modified Files: sqlite-logger.pl Log Message: Let's treat these numbers as, well, numbers. Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -p -r1.56 -r1.57 --- sqlite-logger.pl 11 Aug 2005 15:39:29 -0000 1.56 +++ sqlite-logger.pl 11 Aug 2005 15:46:56 -0000 1.57 @@ -965,11 +965,11 @@ sub linkify { } elsif ($code == 3) { $line =~ m/(\d{1,2})?(,(\d{1,2}))?/; if ($2) { - $color = $1 if $1; + $color = int $1 if $1; $bgcolor = $3; $line =~ s/$1$2//; } elsif ($1) { - $color = $1; + $color = int $1; $line =~ s/$1//; } else { $color = -1; |
|
From: Kevin S. <ks...@us...> - 2005-08-11 15:39:36
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23090/plugins Modified Files: sqlite-logger.pl Log Message: There's no compelling reason these were "16" other than that the array used to have 'inherit' at index 16. -1 is a logically better number to represent that the color is unset. Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -p -r1.55 -r1.56 --- sqlite-logger.pl 11 Aug 2005 15:35:13 -0000 1.55 +++ sqlite-logger.pl 11 Aug 2005 15:39:29 -0000 1.56 @@ -949,8 +949,8 @@ sub linkify { my $bold = 0; my $reverse = 0; my $underline = 0; - my $color = 16; - my $bgcolor = 16; + my $color = -1; + my $bgcolor = -1; my $tag = ''; while(my @codes = $line =~ m/(?:&#(2|3|15|22|31);)+/) { @@ -972,15 +972,15 @@ sub linkify { $color = $1; $line =~ s/$1//; } else { - $color = 16; - $bgcolor = 16; + $color = -1; + $bgcolor = -1; } } else { $bold = 0; $underline = 0; $reverse = 0; - $color = 16; - $bgcolor = 16; + $color = -1; + $bgcolor = -1; } } #end foreach code @@ -994,8 +994,8 @@ sub linkify { ($bold ? 'bold ' : '') . ($underline ? 'uline ' : '') . ($reverse ? 'reverse ' - : ($color != 16 ? "color$color " : '') - . ($bgcolor != 16 ? "bgcolor$color " : '') + : ($color != -1 ? "color$color " : '') + . ($bgcolor != -1 ? "bgcolor$color " : '') ); $tag .= "<span class=\"$class\">" if ($class ne ""); |
|
From: Kevin S. <ks...@us...> - 2005-08-11 15:39:36
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23090 Modified Files: simbot.pl Log Message: There's no compelling reason these were "16" other than that the array used to have 'inherit' at index 16. -1 is a logically better number to represent that the color is unset. Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.137 retrieving revision 1.138 diff -u -d -p -r1.137 -r1.138 --- simbot.pl 9 Aug 2005 01:52:57 -0000 1.137 +++ simbot.pl 11 Aug 2005 15:39:28 -0000 1.138 @@ -505,8 +505,8 @@ sub htmlize { my $bold = 0; my $reverse = 0; my $underline = 0; - my $color = 16; - my $bgcolor = 16; + my $color = -1; + my $bgcolor = -1; my $tag = ""; $line =~ s/&/&/; $line =~ s/>/>/; @@ -536,16 +536,16 @@ sub htmlize { $color = $1; $line =~ s/\003$1/\003/; } else { - $color = 16; - $bgcolor = 16; + $color = -1; + $bgcolor = -1; } debug (DEBUG_SPAM, "htmlize: c: $color; bgc: $bgcolor\n"); } else { $bold = 0; $underline = 0; $reverse = 0; - $color = 16; - $bgcolor = 16; + $color = -1; + $bgcolor = -1; debug (DEBUG_SPAM, "htmlize: b: $bold; u: $underline; r $reverse; c: $color; bgc: $bgcolor\n"); } } #end foreach code @@ -558,8 +558,8 @@ sub htmlize { my $css = ($bold ? "font-weight: bold; " : "") . ($underline ? "text-decoration: underline; " : "") . ($reverse ? "color: white; background: black; " - : ($color != 16 ? "color: $named_colors[$color]; " : "") - . ($bgcolor != 16 ? "background: $named_colors[$bgcolor]; " : "") + : ($color != -1 ? "color: $named_colors[$color]; " : "") + . ($bgcolor != -1 ? "background: $named_colors[$bgcolor]; " : "") ); debug (DEBUG_SPAM, "htmlize: css: $css\n"); $tag .= "<span style=\"$css\">" if ($css ne ""); |
|
From: Pete P. <fou...@us...> - 2005-08-11 15:35:23
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22095/plugins Modified Files: sqlite-logger.pl Log Message: Properly remove the color code when we replace it with style tags. Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -p -r1.54 -r1.55 --- sqlite-logger.pl 11 Aug 2005 15:25:29 -0000 1.54 +++ sqlite-logger.pl 11 Aug 2005 15:35:13 -0000 1.55 @@ -967,10 +967,10 @@ sub linkify { if ($2) { $color = $1 if $1; $bgcolor = $3; - $line =~ s/\003$1$2/\003/; + $line =~ s/$1$2//; } elsif ($1) { $color = $1; - $line =~ s/\003$1/\003/; + $line =~ s/$1//; } else { $color = 16; $bgcolor = 16; |
|
From: Pete P. <fou...@us...> - 2005-08-11 15:32:41
|
Update of /cvsroot/simbot/simbot/templates/css In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21527/templates/css Modified Files: main.default.css Log Message: Colors! Index: main.default.css =================================================================== RCS file: /cvsroot/simbot/simbot/templates/css/main.default.css,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- main.default.css 11 Aug 2005 15:25:29 -0000 1.1 +++ main.default.css 11 Aug 2005 15:32:30 -0000 1.2 @@ -33,7 +33,43 @@ span.nick { } .row.kicked { color: #500; } -.bold { font-weight: bold; } -.uline { text-decoration: underline; } -.reverse { color: #FFF; background-color: #000; } + +.bold { font-weight: bold; } +.uline { text-decoration: underline; } +.reverse { color: #FFF; background-color: #000; } + +.color0 { color: #FFF; } +.color1 { color: #000; } +.color2 { color: navy; } +.color3 { color: green; } +.color4 { color: red; } +.color5 { color: maroon; } +.color6 { color: purple; } +.color7 { color: orange; } +.color8 { color: yellow; } +.color9 { color: lightgreen; } +.color10 { color: teal; } +.color11 { color: cyan; } +.color12 { color: blue; } +.color13 { color: magenta; } +.color14 { color: gray; } +.color15 { color: silver; } + +.bgcolor0 { background-color: #FFF; } +.bgcolor1 { background-color: #000; } +.bgcolor2 { background-color: navy; } +.bgcolor3 { background-color: green; } +.bgcolor4 { background-color: red; } +.bgcolor5 { background-color: maroon; } +.bgcolor6 { background-color: purple; } +.bgcolor7 { background-color: orange; } +.bgcolor8 { background-color: yellow; } +.bgcolor9 { background-color: lightgreen; } +.bgcolor10 { background-color: teal; } +.bgcolor11 { background-color: cyan; } +.bgcolor12 { background-color: blue; } +.bgcolor13 { background-color: magenta; } +.bgcolor14 { background-color: gray; } +.bgcolor15 { background-color: silver; } + |
|
From: Pete P. <fou...@us...> - 2005-08-11 15:25:49
|
Update of /cvsroot/simbot/simbot/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19971/templates Modified Files: base.default.tmpl Log Message: - bold and underline now work in the irc log - colors simply need to be added to the css and they'll work too - httpd will now happily serve CSS files in the templates/css directory. They should be named similarly to templates, so a request for main.css will use main.local.css if it exists, otherwise it'll use main.default.css. - Moved the CSS from the base template to an external file. Index: base.default.tmpl =================================================================== RCS file: /cvsroot/simbot/simbot/templates/base.default.tmpl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- base.default.tmpl 10 Aug 2005 16:49:37 -0000 1.4 +++ base.default.tmpl 11 Aug 2005 15:25:29 -0000 1.5 @@ -4,23 +4,8 @@ <!-- SimBot Default Base Template Copy to base.local.tmpl before editing --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="stylesheet" href="/css/main.css" type="text/css" /> <title>SimBot » <TMPL_VAR NAME=title></title> -<style type="text/css"> -h1 { - text-shadow: 4px 4px 5px #AAA; - border-bottom: 1px solid #000; - margin-bottom: 0; -} -#footer { - border-top: 1px solid #000; - margin-top: 0; -} -#content { margin: 1em 0; } -.ts { color: #777; font-size: 90%; margin-right: .5em; } -span.nick { color: #006; font-weight: bold; } -.row { padding: .1em 0 .1em 10em; text-indent: -9em; } -.row.kicked { color: #500; } -</style> </head><body> <h1><TMPL_VAR NAME=title></h1> <div id="content"> |
|
From: Pete P. <fou...@us...> - 2005-08-11 15:25:49
|
Update of /cvsroot/simbot/simbot/templates/css In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19971/templates/css Added Files: .cvsignore main.default.css Log Message: - bold and underline now work in the irc log - colors simply need to be added to the css and they'll work too - httpd will now happily serve CSS files in the templates/css directory. They should be named similarly to templates, so a request for main.css will use main.local.css if it exists, otherwise it'll use main.default.css. - Moved the CSS from the base template to an external file. --- NEW FILE: .cvsignore --- *.local.css --- NEW FILE: main.default.css --- /* SimBot default stylesheet Copy to main.local.css before editing */ h1 { text-shadow: 4px 4px 5px #AAA; border-bottom: 1px solid #000; margin-bottom: 0; } #footer { border-top: 1px solid #000; margin-top: 0; } #content { margin: 1em 0; } /* IRC LOG STYLES */ .ts { color: #777; font-size: 90%; margin-right: .5em; } span.nick { color: #006; font-weight: bold; } .row { padding: .1em 0 .1em 10em; text-indent: -9em; } .row.kicked { color: #500; } .bold { font-weight: bold; } .uline { text-decoration: underline; } .reverse { color: #FFF; background-color: #000; } |
|
From: Pete P. <fou...@us...> - 2005-08-11 15:25:49
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19971/plugins Modified Files: httpd.pl sqlite-logger.pl Log Message: - bold and underline now work in the irc log - colors simply need to be added to the css and they'll work too - httpd will now happily serve CSS files in the templates/css directory. They should be named similarly to templates, so a request for main.css will use main.local.css if it exists, otherwise it'll use main.default.css. - Moved the CSS from the base template to an external file. Index: httpd.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/httpd.pl,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -p -r1.18 -r1.19 --- httpd.pl 11 Aug 2005 13:39:31 -0000 1.18 +++ httpd.pl 11 Aug 2005 15:25:29 -0000 1.19 @@ -53,7 +53,7 @@ sub index_handler { my $response = HTTP::Response->new(200); - my ($req_root) = $request->uri =~ m|^/([^\?]*)|; + my ($req_root) = $request->uri =~ m|^/([^/\?]*)|; &SimBot::debug(3, 'httpd: handling request for ' . $request->uri . ", req root $req_root\n"); my $code = 500; # An error by default. @@ -72,7 +72,9 @@ sub index_handler { foreach my $url (keys %SimBot::hash_plugin_httpd_pages) { my $title = $SimBot::hash_plugin_httpd_pages{$url}->{'title'}; - $msg .= qq(<li><a href="$url">$title</a></li>\n); + if(defined $title) { + $msg .= qq(<li><a href="$url">$title</a></li>\n); + } } $msg .= "</ul>\n"; @@ -205,6 +207,37 @@ sub admin_page { return RC_OK; } +sub serve_css { + my ($request, $response) = @_; + + my ($filename) = $request->uri =~ m{/css/([^/]+)$}; + # should be something like main.css + + $filename =~ s/\.css$//; + # now is something like main + + if(!defined $filename) { return RC_FORBIDDEN; } + # (user didn't ask for anything and we're unwilling to give a list) + + if(-r "templates/css/${filename}.local.css") { + $filename = "templates/css/${filename}.local.css"; + } elsif( -r "templates/css/${filename}.default.css") { + $filename = "templates/css/${filename}.default.css"; + } else { + return RC_NOT_FOUND; + } + + { + local $/; + open(IN, $filename) or return RC_INTERNAL_SERVER_ERROR; + my $content = <IN>; + $response->push_header("Content-Type", "text/css"); + $response->content($content); + close IN; + } + return RC_OK; +} + sub messup_httpd { if(defined &SimBot::option('plugin.httpd', 'admin_user') && length &SimBot::option('plugin.httpd', 'admin_user') > 4 @@ -216,6 +249,7 @@ sub messup_httpd { 'handler' => \&admin_page, }; } + $SimBot::hash_plugin_httpd_pages{'css'} = { 'handler' => \&serve_css, }; } sub cleanup_httpd { Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -p -r1.53 -r1.54 --- sqlite-logger.pl 10 Aug 2005 19:26:52 -0000 1.53 +++ sqlite-logger.pl 11 Aug 2005 15:25:29 -0000 1.54 @@ -31,6 +31,7 @@ package SimBot::plugin::sqlite::logger; use warnings; use strict; +use Data::Dumper; use Time::Local; use HTML::Entities; @@ -943,9 +944,68 @@ sub create_query_hash { } sub linkify { - my @words = split(/\s+/, $_[0]); - my $curWord; + my $line = $_[0]; + + my $bold = 0; + my $reverse = 0; + my $underline = 0; + my $color = 16; + my $bgcolor = 16; + my $tag = ''; + + while(my @codes = $line =~ m/(?:&#(2|3|15|22|31);)+/) { + my $block = $&; + foreach my $code (@codes) { + if ($code == 2) { + $bold = 1 - $bold; + } elsif ($code == 31) { + $underline = 1 - $underline; + } elsif ($code == 22) { + $reverse = 1 - $reverse; + } elsif ($code == 3) { + $line =~ m/(\d{1,2})?(,(\d{1,2}))?/; + if ($2) { + $color = $1 if $1; + $bgcolor = $3; + $line =~ s/\003$1$2/\003/; + } elsif ($1) { + $color = $1; + $line =~ s/\003$1/\003/; + } else { + $color = 16; + $bgcolor = 16; + } + } else { + $bold = 0; + $underline = 0; + $reverse = 0; + $color = 16; + $bgcolor = 16; + } + } #end foreach code + + if ($tag =~ /<span/) { + $tag = "</span>"; + } else { + $tag = ''; + } + my $class = + ($bold ? 'bold ' : '') + . ($underline ? 'uline ' : '') + . ($reverse ? 'reverse ' + : ($color != 16 ? "color$color " : '') + . ($bgcolor != 16 ? "bgcolor$color " : '') + ); + + $tag .= "<span class=\"$class\">" if ($class ne ""); + $line =~ s/$block/$tag/; + } # end while blocks + $line .= "</span>" if ($tag =~ /<span/); + + my @words = split(/\s+/, $line); + my $curWord; + foreach $curWord (@words) { # remove things that commonly surround URLs my ($word_prefix, $word, $word_suffix) = $curWord |
|
From: Pete P. <fou...@us...> - 2005-08-11 15:20:11
|
Update of /cvsroot/simbot/simbot/templates/css In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19253/css Log Message: Directory /cvsroot/simbot/simbot/templates/css added to the repository |
|
From: Kevin S. <ks...@us...> - 2005-08-11 13:51:38
|
Update of /cvsroot/simbot/simbot/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27707 Modified Files: error.404.default.tmpl Log Message: "If you following a link" has a grammar problem or two. Index: error.404.default.tmpl =================================================================== RCS file: /cvsroot/simbot/simbot/templates/error.404.default.tmpl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- error.404.default.tmpl 11 Aug 2005 13:49:35 -0000 1.1 +++ error.404.default.tmpl 11 Aug 2005 13:51:24 -0000 1.2 @@ -2,5 +2,5 @@ not defined on this server. Either this server has no handler registered for this resource or the active handler did not wish to handle it.</p> -<p>Please check the URL and try again. If you following a link on this server, +<p>Please check the URL and try again. If you followed a link on this server, you should report this error to the administrator of the server.</p> \ No newline at end of file |
|
From: Kevin S. <ks...@us...> - 2005-08-11 13:49:43
|
Update of /cvsroot/simbot/simbot/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27268 Added Files: error.404.default.tmpl Log Message: Adding a 404 page --- NEW FILE: error.404.default.tmpl --- <p>The resource <q><TMPL_VAR NAME=request_url></q> indicated by your request is not defined on this server. Either this server has no handler registered for this resource or the active handler did not wish to handle it.</p> <p>Please check the URL and try again. If you following a link on this server, you should report this error to the administrator of the server.</p> |