simbot-commits Mailing List for SimBot (Page 6)
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-07 18:33:37
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26669/plugins Modified Files: sqlite-logger.pl Log Message: - use &SimBot::html_mask_email instead of doing it ourselves. - Don't link things when we can't figure out a protocol. This fixes things like km/h becoming links. Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -p -r1.48 -r1.49 --- sqlite-logger.pl 28 Jul 2005 13:24:38 -0000 1.48 +++ sqlite-logger.pl 7 Aug 2005 18:33:27 -0000 1.49 @@ -991,34 +991,7 @@ sub linkify { if($url =~ m{^(\S+)@(\S+)\.(\S+)$}) { # probably an email address - my ($user, $host) = ($1, "${2}.${3}"); - my ($nuser, $nhost); - for(my $i; $i < length $user; $i++) { - $nuser .= '&#' . ord(substr($user, $i, 1)); - } - for(my $i; $i < length $host; $i++) { - $nhost .= '&#' . ord(substr($host, $i, 1)); - } - - $curWord = <<EOT; -<script type="text/javascript"> -var s='@'; -var w='to:'; -var u='ma'; -var l='$nuser'; -var d='il'; -var p='$nhost'; -document.write('<a href="'); -document.write(u+d); -document.write(w+l); -document.write(s+p); -document.write('">'); -document.write(l); -document.write(s+p); -document.write('</a>'); -</script><noscript>[email removed]</noscript> -EOT - + $curWord = &SimBot::html_mask_email($url); next; } @@ -1035,7 +1008,9 @@ EOT # Yup. Let's assume it's a web site... $host = 'http://' . $host; } - $curWord = qq(<a href="${host}/${path}">$curWord</a>); + if($host =~ m/:/) { + $curWord = qq(<a href="${host}/${path}">$curWord</a>); + } } } return join(' ', @words); |
|
From: Pete P. <fou...@us...> - 2005-08-07 18:25:43
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25342 Modified Files: simbot.pl Log Message: htmlize now masks email addresses (or things that look like email addresses) Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.133 retrieving revision 1.134 diff -u -d -p -r1.133 -r1.134 --- simbot.pl 29 Jul 2005 06:44:40 -0000 1.133 +++ simbot.pl 7 Aug 2005 18:25:26 -0000 1.134 @@ -568,9 +568,52 @@ sub htmlize { $string .= $line . "</div>\n"; } # end foreach lines $string =~ s%(http|ftp)://[^\s\n<>]+%<a href="$&">$&</a>%g; + while($string =~ m/\b(\S+@[a-z\-\.]+\.[a-z]+)/i) { + my $email = $&; + my $masked = &html_mask_email($email); + $string =~ s/$email/$masked/g; + } return $string; } +# HTML_MASK_EMAIL: Returns the HTML for a masked email address. +# Currently, we break the address apart into user and host, +# turn each character into its HTML escaped ascii code, +# and return a simple javascript with the address broken up and out of order +# that, when run, outputs the address properly (and properly linked) +# This doesn't make harvesting impossible, but it does make it more difficult. +# Viewers without javascript see [email removed] instead. +sub html_mask_email { + my ($user, $host) = @_[0] =~ m/^(\S+)@(\S+)$/; + my ($nuser, $nhost); + for(my $i; $i < length $user; $i++) { + $nuser .= '&#' . ord(substr($user, $i, 1)) . ';'; + } + for(my $i; $i < length $host; $i++) { + $nhost .= '&#' . ord(substr($host, $i, 1)) . ';'; + } + + return <<EOT; +<script type="text/javascript"> +var p='$nhost'; +var w='to:'; +var l='$nuser'; +var u='ma'; +var s='@'; +var d='il'; +document.write('<a href="'); +document.write(u+d); +document.write(w+l); +document.write(s+p); +document.write('">'); +document.write(l); +document.write(s+p); +document.write('</a>'); +</script><noscript>[email removed]</noscript> +EOT + +} + # NUMBERIZE: Find all the word-based numbers in a string and replace them # with digit-based numbers. sub numberize { |
|
From: Kevin S. <ks...@us...> - 2005-07-29 06:44:48
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25622/plugins Modified Files: recap.pl Log Message: Fix two small bugs: services. sets mode TheSimBot +e is not a channel mode change; recap was logging /me with the nickname doubled. Index: recap.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/recap.pl,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -p -r1.19 -r1.20 --- recap.pl 28 Jul 2005 01:05:55 -0000 1.19 +++ recap.pl 29 Jul 2005 06:44:40 -0000 1.20 @@ -76,7 +76,7 @@ sub record_recap { if ($doing eq 'SAY') { $line .= "<$nick> $content"; } elsif ($doing eq 'ACTION') { - $line .= "* $nick $content"; + $line .= "* $content"; } elsif ($doing eq 'KICKED') { $line .= "$target kicked $nick from $channel" . ($content ? " ($content)" : ""); $departs{$nick} = 0; |
|
From: Kevin S. <ks...@us...> - 2005-07-29 06:44:48
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25622 Modified Files: simbot.pl Log Message: Fix two small bugs: services. sets mode TheSimBot +e is not a channel mode change; recap was logging /me with the nickname doubled. Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.132 retrieving revision 1.133 diff -u -d -p -r1.132 -r1.133 --- simbot.pl 28 Jul 2005 00:50:09 -0000 1.132 +++ simbot.pl 29 Jul 2005 06:44:40 -0000 1.133 @@ -1962,7 +1962,8 @@ sub channel_topic { sub channel_mode { my ($nick) = split(/!/, $_[ ARG0 ]); my ($chan, $modes, @args) = @_[ ARG1, ARG2, ARG3 .. $#_ ]; - if ($nick ne $chan) { + # If the mode change was made on the bot, it is not a channel mode. + if ($chan ne $chosen_nick) { &debug(DEBUG_STD, "$nick set mode $modes @args in $chan.\n"); foreach(keys(%event_channel_mode)) { &plugin_callback($_, $event_channel_mode{$_}, ($nick, $chan, 'MODE', $modes, @args)); @@ -2119,6 +2120,8 @@ sub server_supports { # nicely. Right now many plugins assume that the channel we are # in is the channel defined in the config file, which may # not be true. + # The changes necessary to do this will make multi-channel + # support easier in the future. $kernel->post(bot => mode => $chosen_nick => '+Q'); } |
|
From: Pete P. <fou...@us...> - 2005-07-28 13:24:46
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15884/plugins Modified Files: sqlite-logger.pl Log Message: Dates now work. Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -p -r1.47 -r1.48 --- sqlite-logger.pl 28 Jul 2005 13:18:28 -0000 1.47 +++ sqlite-logger.pl 28 Jul 2005 13:24:38 -0000 1.48 @@ -700,24 +700,27 @@ sub row_hashref_to_text { sub row_hashref_to_html { my ($row) = @_; + my $msg = '<div class="row ' . lc($row->{'event'}) . '">'; + + + # timestamp my (undef, undef, undef, $cur_day, $cur_month, $cur_yr) = localtime; $cur_month += 1; # localtime gives us 0..11, we want 1..12 $cur_yr += 1900; # localtime gives us number of years since 1900 - my $msg = '<div class="row ' . lc($row->{'event'}) . '">'; - - - # timestamp - my ($yr, $month, $day, $hr,$min) = $row->{'time'} =~ m/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/; + my (undef, $min, $hr, $day, $month, $yr) = localtime($row->{'time'}); + $month += 1; + $yr += 1900; - $msg .= q(<span class="ts">); + $msg .= '<span class="ts">'; if($cur_day != $day || $cur_month != $month || $cur_yr != $yr) { $msg .= (MONTHS)[$month-1] . " $day "; } - $msg .= "$hr:$min"; - $msg .= q(</span>); + if($cur_yr != $yr) { $msg .= "$yr "; } + + $msg .= $hr . ':' . sprintf('%02d',$min) . '</span> '; # event # $msg .= q(<span class=") . lc($row->{'event'}) . q(">); |
|
From: Pete P. <fou...@us...> - 2005-07-28 13:18:37
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14471/plugins Modified Files: sqlite-logger.pl Log Message: The web log viewer is back! This was mostly copy/pasted from a CGI script I made for the old mysql logger... Lots of warnings, lots of fugly, but it works. Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -p -r1.46 -r1.47 --- sqlite-logger.pl 25 Jul 2005 09:34:18 -0000 1.46 +++ sqlite-logger.pl 28 Jul 2005 13:18:28 -0000 1.47 @@ -32,6 +32,9 @@ package SimBot::plugin::sqlite::logger; use warnings; use strict; +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 DBI; @@ -694,6 +697,101 @@ sub row_hashref_to_text { return $msg; } +sub row_hashref_to_html { + my ($row) = @_; + + my (undef, undef, undef, $cur_day, $cur_month, $cur_yr) = localtime; + $cur_month += 1; # localtime gives us 0..11, we want 1..12 + $cur_yr += 1900; # localtime gives us number of years since 1900 + + my $msg = '<div class="row ' . lc($row->{'event'}) . '">'; + + + # timestamp + my ($yr, $month, $day, $hr,$min) = $row->{'time'} =~ m/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/; + + $msg .= q(<span class="ts">); + + if($cur_day != $day || $cur_month != $month || $cur_yr != $yr) { + $msg .= (MONTHS)[$month-1] . " $day "; + } + $msg .= "$hr:$min"; + + $msg .= q(</span>); + + # event +# $msg .= q(<span class=") . lc($row->{'event'}) . q(">); + $msg .= q(<span class="msg">); + + if($row->{'event'} eq 'SAY') { + $msg .= '<' . &f_nick($row->{'source_nick_id'}) + . '> ' . f_content($row->{'content'}); + } elsif($row->{'event'} eq 'NOTICE') { + $msg .= '-' . &f_nick($row->{'source_nick_id'}) + . '- ' . f_content($row->{'content'}); + } elsif($row->{'event'} eq 'ACTION') { + $msg .= '* ' . &f_nick($row->{'source_nick_id'}) + . ' ' . f_content($row->{'content'}); + } elsif($row->{'event'} eq 'JOINED') { + $msg .= '* ' . &f_nick($row->{'source_nick_id'}) + . ' joined.'; + } elsif($row->{'event'} eq 'PARTED') { + $msg .= '* ' . &f_nick($row->{'source_nick_id'}) + . ' left (' . f_content($row->{'content'}) . ')'; + } elsif($row->{'event'} eq 'QUIT') { + $msg .= '* ' . &f_nick($row->{'source_nick_id'}) + . ' quit (' . f_content($row->{'content'}) . ')'; + } elsif($row->{'event'} eq 'TOPIC') { + $msg .= '* ' . &f_nick($row->{'source_nick_id'}) + . ' changed the topic to: ' . f_content($row->{'content'}); + } elsif($row->{'event'} eq 'MODE') { + $msg .= '* ' . &f_nick($row->{'source_nick_id'}) + . ' set ' . f_content($row->{'content'}); + } elsif($row->{'event'} eq 'KICKED') { + $msg .= '* ' . &f_nick($row->{'target_nick_id'}) + . ' was kicked by ' . &f_nick($row->{'source_nick_id'}) + . ' (' . f_content($row->{'content'}) . ')'; + } elsif($row->{'event'} eq 'NICK') { + $msg .= '* ' . &f_nick($row->{'source_nick_id'}) + . ' is now known as ' . &f_nick($row->{'target_nick_id'}); + + } else { # Oh, great, we forgot one. + $msg .= 'UNKNOWN EVENT ' . $row->{'event'} . ':'; + if(defined $row->{'source_nick_id'}) + { $msg .= ' source:' . &f_nick($row->{'source_nick_id'}); } + if(defined $row->{'target_nick_id'}) + { $msg .= ' target:' . &f_nick($row->{'target_nick_id'}); } + if(defined f_content($row->{'content'})) + { $msg .= ' content:' . f_content($row->{'content'}); } + } + $msg .= q(</span></div>); + return $msg; +} + + +### FORMATTING FUNCTIONS ### +sub f_nick { + return '<span class="nick">' + . &get_nickchan_name($_[0]) + . '</span>'; +} + +# f_content is used to format the content part of chat. +# this does things like linkify URLs, escape characters that +# need escaping, munge email addresses, and things like that. +sub f_content { + my $content = encode_entities($_[0]); + + # mask email + + + # linkify + $content = &linkify($content); + + return $content; +} + + sub get_nick_context { my ($nick_id) = @_; @@ -764,6 +862,182 @@ sub seen_nlp_match { } } +sub web_request { + my ($request, $response) = @_; + + my $query = &create_query_hash($request->uri); + + if(defined $query->{'recap'}) { + &web_recap($query, $response); + } else { + &web_log($query, $response); + } +} + +sub web_recap { + my ($query, $response) = @_; + + +} + +sub web_log { + my ($query, $response) = @_; + my (undef, undef, undef, $start_day, $start_month, $start_year) + = localtime; + + $start_month += 1; + $start_year += 1900; + + my ($start_hour, $start_min, $end_hour, $end_min); + $start_hour = $start_min = 0; + $end_hour = 23; + $end_min = 59; + + my $channel_id = (defined $query->{'channel_id'} + ? $query->{'channel_id'} + : &get_nickchan_id(&SimBot::option('network', 'channel'))); + + if(defined $query->{'smo'}) + { $start_month = $query->{'smo'}; } + if(defined $query->{'sdy'}) + { $start_day = $query->{'sdy'}; } + if(defined $query->{'syr'}) + { $start_year = $query->{'syr'}; } + if(defined $query->{'shr'}) + { $start_hour = $query->{'shr'}; } + if(defined $query->{'smn'}) + { $start_min = $query->{'smn'}; } + + # If the end day, month, year aren't set, assume the same as the + # start + my ($end_day, $end_month, $end_year) + = ($start_day, $start_month, $start_year); + + if(defined $query->{'emo'}) + { $end_month = $query->{'emo'}; } + if(defined $query->{'edy'}) + { $end_day = $query->{'edy'}; } + if(defined $query->{'eyr'}) + { $end_year = $query->{'eyr'}; } + if(defined $query->{'ehr'}) + { $end_hour = $query->{'ehr'}; } + if(defined $query->{'emn'}) + { $end_min = $query->{'emn'}; } + + my $start_time = timelocal(0,$start_min,$start_hour,$start_day, $start_month-1, $start_year); + my $end_time = timelocal(59,$end_min,$end_hour,$end_day, $end_month-1, $end_year); + + my $message = + '<div id="header">IRC log for ' + . &get_nickchan_name($channel_id) + . ' from ' . scalar localtime($start_time) + . ' to ' . scalar localtime($end_time) + . '. Generated ' . scalar localtime() + . "</div>\n"; + + my $log_query = $dbh->prepare_cached( + 'SELECT time, source_nick_id, event, target_nick_id, content' + . ' FROM chatlog' + . ' WHERE channel_id = ?' + . ' AND time >= ?' + . ' AND time <= ?' + ); + + $log_query->execute($channel_id, $start_time, $end_time); + + my $row; + while($row = $log_query->fetchrow_hashref) { + $message .= &row_hashref_to_html($row) . "\n"; + } + $response->content($message); + $response->push_header("Content-Type", "text/html"); +} + +sub create_query_hash { + my ($query) = $_[0] =~ m/\?(\S+)$/; + my %hash; + if(!defined $query) { return \%hash; } + + foreach my $cur_query (split(/&/, $query)) { + my ($key, $value) = $cur_query =~ m/^(\S+)(?:=(\S+))$/; + + if(!defined $value) { $value = 1; } + + $hash{$key} = $value; + } + + return \%hash; +} + +sub linkify { + my @words = split(/\s+/, $_[0]); + my $curWord; + + foreach $curWord (@words) { + my $url = $curWord; + + # remove things that commonly surround URLs + $url =~ s{^\(}{}; + $url =~ s{\)$}{}; + $url =~ s{^<}{}; + $url =~ s{>$}{}; + + # map some common host names to protocols + $url =~ s{^(www|web)\.} {http://$1\.}; + $url =~ s{^ftp\.} {ftp://ftp\.}; + + if($url =~ m{^(\S+)@(\S+)\.(\S+)$}) { + # probably an email address + my ($user, $host) = ($1, "${2}.${3}"); + my ($nuser, $nhost); + for(my $i; $i < length $user; $i++) { + $nuser .= '&#' . ord(substr($user, $i, 1)); + } + for(my $i; $i < length $host; $i++) { + $nhost .= '&#' . ord(substr($host, $i, 1)); + } + + $curWord = <<EOT; +<script type="text/javascript"> +var s='@'; +var w='to:'; +var u='ma'; +var l='$nuser'; +var d='il'; +var p='$nhost'; +document.write('<a href="'); +document.write(u+d); +document.write(w+l); +document.write(s+p); +document.write('">'); +document.write(l); +document.write(s+p); +document.write('</a>'); +</script><noscript>[email removed]</noscript> +EOT + + next; + } + + if($url =~ m{^((http|ftp|news|nntp|irc|aim)s?:[\w.?/=\-\&]+)}) { + $curWord = qq(<a href="$1">$curWord</a>); + next; + } + + if(my ($host, $path) = $url =~ m{(.+?)/(.*)}) { + # does the first segment have a TLD? + if($host =~ m{\.(com|org|net|edu|gov|mil|int + |biz|pro|info|aero|coop|name + |museum|\w\w)$}ix) { + # Yup. Let's assume it's a web site... + $host = 'http://' . $host; + } + $curWord = qq(<a href="${host}/${path}">$curWord</a>); + } + } + return join(' ', @words); +} + &SimBot::plugin_register( plugin_id => 'log', event_plugin_call => \&access_log, @@ -798,4 +1072,7 @@ sub seen_nlp_match { hash_plugin_nlp_questions => ['have-you', 'did-you', 'when-is', ], ); - +$SimBot::hash_plugin_httpd_pages{'log'} = { + 'title' => 'Log Viewer', + 'handler' => \&web_request, +} |
|
From: Pete P. <fou...@us...> - 2005-07-28 01:56:51
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16313/plugins Modified Files: httpd.pl Log Message: PoCo::Server::HTTP's out. POE::Filter::HTTPD is in. We weren't using anything PoCo::Server::HTTP added anyway. Index: httpd.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/httpd.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -p -r1.9 -r1.10 --- httpd.pl 28 Jul 2005 01:17:25 -0000 1.9 +++ httpd.pl 28 Jul 2005 01:56:26 -0000 1.10 @@ -21,31 +21,54 @@ use warnings; use strict; use POE; -use POE::Component::Server::HTTP; +use POE::Component::Server::TCP; +use POE::Filter::HTTPD; +#use POE::Component::Server::HTTP; use HTTP::Status; our $aliases; #our $kernel; use vars qw( $kernel ); -$aliases = POE::Component::Server::HTTP->new( -# Alias => 'simbot_plugin_httpd', - Port => (defined &SimBot::option('plugin.httpd', 'port') - ? &SimBot::option('plugin.httpd', 'port') - : 8000), - ContentHandler => { - '/' => \&index_handler, - }, - Headers => { - Server => 'SimBot', - }, +#$aliases = POE::Component::Server::HTTP->new( +## Alias => 'simbot_plugin_httpd', +# Port => (defined &SimBot::option('plugin.httpd', 'port') +# ? &SimBot::option('plugin.httpd', 'port') +# : 8000), +# ContentHandler => { +# '/' => \&index_handler, +# }, +# Headers => { +# Server => 'SimBot', +# }, +#); + +POE::Component::Server::TCP->new( + Alias => 'web_server', + Port => (defined &SimBot::option('plugin.httpd', 'port') + ? &SimBot::option('plugin.httpd', 'port') + : 8000), + ClientFilter => 'POE::Filter::HTTPD', + + ClientInput => \&index_handler, ); sub index_handler { - # build and display a index of what is available - my ($request, $response) = @_; + my ($kernel, $heap, $request) = @_[KERNEL, HEAP, ARG0]; +# my ($request, $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 ($req_root) = $request->uri =~ m|^http://.*?/([^/\?]*)|; + my $response = HTTP::Response->new(200); + + #my ($req_root) = $request->uri =~ m|^http://.*?/([^/\?]*)|; + my ($req_root) = $request->uri =~ m|^/([^\?]*)|; &SimBot::debug(3, 'httpd: handling request for ' . $request->uri . ", req root $req_root\n"); @@ -66,7 +89,9 @@ sub index_handler { $response->code(RC_OK); # assume everything's OK } - return RC_OK; + $heap->{client}->put($response); + $kernel->yield('shutdown'); + return; } my $msg = &page_header('SimBot'); @@ -81,7 +106,9 @@ sub index_handler { $response->code(RC_OK); $response->push_header("Content-Type", "text/html"); $response->content($msg); - return RC_OK; + + $heap->{client}->put($response); + $kernel->yield('shutdown'); } sub page_header { @@ -171,8 +198,7 @@ sub messup_httpd { sub cleanup_httpd { &SimBot::debug(3, "httpd: Shutting down..."); - POE::Kernel->call($aliases->{httpd}, 'shutdown'); - POE::Kernel->call($aliases->{tcp}, "shutdown"); + POE::Kernel->call('web_server', 'shutdown'); &SimBot::debug(3, " ok\n"); } |
|
From: Pete P. <fou...@us...> - 2005-07-28 01:56:51
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16313 Modified Files: INSTALL Log Message: PoCo::Server::HTTP's out. POE::Filter::HTTPD is in. We weren't using anything PoCo::Server::HTTP added anyway. Index: INSTALL =================================================================== RCS file: /cvsroot/simbot/simbot/INSTALL,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -p -r1.25 -r1.26 --- INSTALL 27 Jul 2005 13:44:26 -0000 1.25 +++ INSTALL 28 Jul 2005 01:56:26 -0000 1.26 @@ -61,7 +61,7 @@ intend to use any of the stock plugins p * Required by: time -[ POE::Component::Server::HTTP ] +[ POE::Filter::HTTPD ] * Required by: httpd |
|
From: Pete P. <fou...@us...> - 2005-07-28 01:17:39
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6306/plugins Modified Files: httpd.pl Log Message: We should be returning RC_OK, although I don't see it making a difference... Index: httpd.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/httpd.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -p -r1.8 -r1.9 --- httpd.pl 28 Jul 2005 00:09:49 -0000 1.8 +++ httpd.pl 28 Jul 2005 01:17:25 -0000 1.9 @@ -29,7 +29,7 @@ our $aliases; use vars qw( $kernel ); $aliases = POE::Component::Server::HTTP->new( - Alias => 'simbot_plugin_httpd', +# Alias => 'simbot_plugin_httpd', Port => (defined &SimBot::option('plugin.httpd', 'port') ? &SimBot::option('plugin.httpd', 'port') : 8000), @@ -53,8 +53,11 @@ sub index_handler { my $handler = $SimBot::hash_plugin_httpd_pages{$req_root}->{'handler'}; &$handler($request, $response); - if(!defined $response->content - || length $response->content == 0) { + if(defined $response->code && $response->code == RC_UNAUTHORIZED) { + $response->content('Bad login/pass or your browser does not know how to log in.'); + } elsif(!defined $response->content + || length $response->content == 0) + { # Hey! Our plugin didn't do anything useful. $response->code(RC_INTERNAL_SERVER_ERROR); $response->content("something's broken"); @@ -63,7 +66,7 @@ sub index_handler { $response->code(RC_OK); # assume everything's OK } - return; + return RC_OK; } my $msg = &page_header('SimBot'); @@ -78,6 +81,7 @@ sub index_handler { $response->code(RC_OK); $response->push_header("Content-Type", "text/html"); $response->content($msg); + return RC_OK; } sub page_header { @@ -123,7 +127,9 @@ sub admin_page { if(!defined $kernel) { warn "Trying to restart simbot without a kernel"; } - $kernel->post('simbot', 'restart', "web admin"); + POE::Kernel->post('simbot', 'restart', "web admin"); + $response->code(RC_OK); + $response->content('OK, restarting'); return; } elsif(my ($say) = $request->uri =~ m|\?say=(\S+)$|) { $say =~ s/\+/ /g; @@ -145,9 +151,7 @@ sub admin_page { $response->content($msg); } -sub messup_httpd { - $kernel = $_[0]; - +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') @@ -166,8 +170,10 @@ sub messup_httpd { } sub cleanup_httpd { - $kernel->call($aliases->{httpd}, 'shutdown'); - undef $aliases; + &SimBot::debug(3, "httpd: Shutting down..."); + POE::Kernel->call($aliases->{httpd}, 'shutdown'); + POE::Kernel->call($aliases->{tcp}, "shutdown"); + &SimBot::debug(3, " ok\n"); } &SimBot::plugin_register( |
|
From: Pete P. <fou...@us...> - 2005-07-28 01:06:04
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3156/plugins Modified Files: recap.pl Log Message: Update recap to match a change to httpd Index: recap.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/recap.pl,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -p -r1.18 -r1.19 --- recap.pl 27 Jul 2005 17:37:18 -0000 1.18 +++ recap.pl 28 Jul 2005 01:05:55 -0000 1.19 @@ -141,7 +141,7 @@ sub recap_page { event_server_nick => \&nick_change, ); -$SimBot::hash_plugin_httpd_pages{'/recap'} = { +$SimBot::hash_plugin_httpd_pages{'recap'} = { 'title' => "Current Chatter", 'handler' => \&recap_page, } |
|
From: Pete P. <fou...@us...> - 2005-07-28 00:50:24
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31906 Modified Files: simbot.pl Log Message: Now to commit the changes I intended... - Give an alias to the simbot session so I can throw the restart event from httpd.pl Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.131 retrieving revision 1.132 diff -u -d -p -r1.131 -r1.132 --- simbot.pl 28 Jul 2005 00:41:58 -0000 1.131 +++ simbot.pl 28 Jul 2005 00:50:09 -0000 1.132 @@ -1982,6 +1982,8 @@ sub initialize { $kernel->sig( USR1 => 'restart' ); $kernel->sig( USR2 => 'rehash' ); + $kernel->alias_set('simbot'); # so plugins can talk back to us + $kernel->post(bot => register => "all"); &irc_connect; @@ -2046,7 +2048,6 @@ sub irc_disconnected { # Everyone out of the pool! foreach(keys(%event_plugin_unload)) { - &SimBot::debug(DEBUG_STD, "Unloading $_\n"); &plugin_callback($_, $event_plugin_unload{$_}); } |
|
From: Pete P. <fou...@us...> - 2005-07-28 00:42:08
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30110 Modified Files: simbot.pl Log Message: Rolling back to 1.129 Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.130 retrieving revision 1.131 diff -u -d -p -r1.130 -r1.131 --- simbot.pl 28 Jul 2005 00:09:49 -0000 1.130 +++ simbot.pl 28 Jul 2005 00:41:58 -0000 1.131 @@ -107,6 +107,11 @@ our %numbers_digits = (one => 1, two => six => 6, seven => 7, eight => 8, nine => 9, ); + +our @named_colors = ("white", "black", "navy", "green", "red", "maroon", + "purple", "orange", "yellow", "lightgreen", "teal", + "cyan", "blue", "magenta", "gray", "silver"); + # **************************************** # ************ Start of Script *********** # **************************************** @@ -282,11 +287,6 @@ if(option('chat', 'delete_usage_max') != ); } -# We'll need this perl module to be able to do anything meaningful. -use POE; -use POE::Component::IRC; -our $kernel = new POE::Kernel; - # Now that we've initialized the callback tables, let's load # all the plugins that we can from the plugins directory. opendir(DIR, "./plugins"); @@ -327,6 +327,12 @@ our $snooze = (option('chat','snooze') = # Load the massive table of rules simbot will need. &load; +# Now that everything is loaded, let's prepare to connect to IRC. +# We'll need this perl module to be able to do anything meaningful. +our $kernel = new POE::Kernel; +use POE; +use POE::Component::IRC; + # Create a new IRC connection. POE::Component::IRC->new('bot'); @@ -489,6 +495,82 @@ sub parse_style { return $_; } +# HTMLIZE: Converts IRC color codes, links into HTML. +sub htmlize { + my @lines = split(/\n/, $_[0]); + my $string = ""; + foreach my $line (@lines) { + my $bold = 0; + my $reverse = 0; + my $underline = 0; + my $color = 16; + my $bgcolor = 16; + my $tag = ""; + $line =~ s/&/&/; + $line =~ s/>/>/; + $line =~ s/</</; + $line = "<div>" . $line; + while($line =~ m/[\002\003\017\026\037]+/) { + my $block = $&; + my @codes = split(//, $block); + debug (DEBUG_SPAM, "htmlize: codes: " . (@codes) . "\n"); + foreach my $code (@codes) { + if ($code eq "\002") { + $bold = 1 - $bold; + debug (DEBUG_SPAM, "htmlize: bold: $bold\n"); + } elsif ($code eq "\037") { + $underline = 1 - $underline; + debug (DEBUG_SPAM, "htmlize: underline: $underline\n"); + } elsif ($code eq "\026") { + $reverse = 1 - $reverse; + debug (DEBUG_SPAM, "htmlize: reverse: $reverse\n"); + } elsif ($code eq "\003") { + $line =~ m/\003(\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; + } + debug (DEBUG_SPAM, "htmlize: c: $color; bgc: $bgcolor\n"); + } else { + $bold = 0; + $underline = 0; + $reverse = 0; + $color = 16; + $bgcolor = 16; + debug (DEBUG_SPAM, "htmlize: b: $bold; u: $underline; r $reverse; c: $color; bgc: $bgcolor\n"); + } + } #end foreach code + debug (DEBUG_SPAM, "htmlize: old tag: $tag\n"); + if ($tag =~ /<span style=.*>/) { + $tag = "</span>"; + } else { + $tag = ""; + } + 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]; " : "") + ); + debug (DEBUG_SPAM, "htmlize: css: $css\n"); + $tag .= "<span style=\"$css\">" if ($css ne ""); + debug (DEBUG_SPAM, "htmlize: new tag: $tag\n"); + $line =~ s/$block/$tag/; + } # end while blocks + $line .= "</span>" if ($tag =~ /<span style=.*>/); + $string .= $line . "</div>\n"; + } # end foreach lines + $string =~ s%(http|ftp)://[^\s\n<>]+%<a href="$&">$&</a>%g; + return $string; +} + # NUMBERIZE: Find all the word-based numbers in a string and replace them # with digit-based numbers. sub numberize { @@ -709,7 +791,7 @@ sub load { $chat_words{$rule[1]}{$rule[0]}[0] = $rule[2]; } close(RULES); - &debug(DEBUG_STD, "Rules loaded successfully!\n"); + &debug(DEBUG_STD, "Rules loaded successfully!\n", DEBUG_NO_PREFIX); $loaded = 1; &debug(DEBUG_STD, "Checking for lost words... "); @@ -881,9 +963,6 @@ sub plugin_register { # PLUGIN_CALLBACK: Calls the given plugin function with paramters. sub plugin_callback { - if(!defined $kernel) { - warn 'In plugin_callback before $kernel is defined'; - } my ($plugin, $function, @params) = @_; debug(DEBUG_SPAM, "Running callback to $function in $plugin.\n"); return &$function($kernel, @params); @@ -1710,10 +1789,6 @@ sub private_message { sub channel_message { my ($nick) = split(/!/, $_[ ARG0 ]); my ($channel, $text) = @_[ ARG1, ARG2 ]; - $text =~ s/\003\d{0,2},?\d{0,2}//g; - $text =~ s/[\002\017\026\037]//g; - - &debug(DEBUG_STD, "[@{$channel}:$nick] $text\n"); my $prefix = option('global', 'command_prefix'); my $nickmatch = "(" . $chosen_nick . "|" . @@ -1725,6 +1800,14 @@ sub channel_message { &plugin_callback($_, $event_channel_message{$_}, ($nick, $channel, 'SAY', $text)); } + # We pass the original string to plugins. Then, we strip out formatting + # codes. Who knows? Someone might want to log things exactly as they + # were. + $text =~ s/\003\d{0,2},?\d{0,2}//g; + $text =~ s/[\002\017\026\037]//g; + + &debug(DEBUG_STD, "[@{$channel}:$nick] $text\n"); + if ($text =~ /^\Q$prefix\E/) { my @command = split(/\s/, $text); my $cmd = $command[0]; @@ -1899,8 +1982,6 @@ sub initialize { $kernel->sig( USR1 => 'restart' ); $kernel->sig( USR2 => 'rehash' ); - $kernel->alias_set('simbot'); # so plugins can talk back to us - $kernel->post(bot => register => "all"); &irc_connect; @@ -1965,9 +2046,13 @@ sub irc_disconnected { # Everyone out of the pool! foreach(keys(%event_plugin_unload)) { + &SimBot::debug(DEBUG_STD, "Unloading $_\n"); &plugin_callback($_, $event_plugin_unload{$_}); } + # remove our alias + $kernel->alias_remove('simbot'); + # since the event loop should soon have nothing to do # it'll exit. Or something like that. } else { @@ -2091,9 +2176,6 @@ sub quit_session { # remove any alarms. This stops any verbose output simbot was giving $kernel->alarm_remove_all( ); - - # remove our alias - $kernel->alias_remove('simbot'); $kernel->sig_handled(); } |
|
From: Pete P. <fou...@us...> - 2005-07-28 00:09:59
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21267 Modified Files: simbot.pl Log Message: Closer to getting restart in the admin page working. Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.129 retrieving revision 1.130 diff -u -d -p -r1.129 -r1.130 --- simbot.pl 27 Jul 2005 17:37:17 -0000 1.129 +++ simbot.pl 28 Jul 2005 00:09:49 -0000 1.130 @@ -107,11 +107,6 @@ our %numbers_digits = (one => 1, two => six => 6, seven => 7, eight => 8, nine => 9, ); - -our @named_colors = ("white", "black", "navy", "green", "red", "maroon", - "purple", "orange", "yellow", "lightgreen", "teal", - "cyan", "blue", "magenta", "gray", "silver"); - # **************************************** # ************ Start of Script *********** # **************************************** @@ -287,6 +282,11 @@ if(option('chat', 'delete_usage_max') != ); } +# We'll need this perl module to be able to do anything meaningful. +use POE; +use POE::Component::IRC; +our $kernel = new POE::Kernel; + # Now that we've initialized the callback tables, let's load # all the plugins that we can from the plugins directory. opendir(DIR, "./plugins"); @@ -327,12 +327,6 @@ our $snooze = (option('chat','snooze') = # Load the massive table of rules simbot will need. &load; -# Now that everything is loaded, let's prepare to connect to IRC. -# We'll need this perl module to be able to do anything meaningful. -our $kernel = new POE::Kernel; -use POE; -use POE::Component::IRC; - # Create a new IRC connection. POE::Component::IRC->new('bot'); @@ -495,82 +489,6 @@ sub parse_style { return $_; } -# HTMLIZE: Converts IRC color codes, links into HTML. -sub htmlize { - my @lines = split(/\n/, $_[0]); - my $string = ""; - foreach my $line (@lines) { - my $bold = 0; - my $reverse = 0; - my $underline = 0; - my $color = 16; - my $bgcolor = 16; - my $tag = ""; - $line =~ s/&/&/; - $line =~ s/>/>/; - $line =~ s/</</; - $line = "<div>" . $line; - while($line =~ m/[\002\003\017\026\037]+/) { - my $block = $&; - my @codes = split(//, $block); - debug (DEBUG_SPAM, "htmlize: codes: " . (@codes) . "\n"); - foreach my $code (@codes) { - if ($code eq "\002") { - $bold = 1 - $bold; - debug (DEBUG_SPAM, "htmlize: bold: $bold\n"); - } elsif ($code eq "\037") { - $underline = 1 - $underline; - debug (DEBUG_SPAM, "htmlize: underline: $underline\n"); - } elsif ($code eq "\026") { - $reverse = 1 - $reverse; - debug (DEBUG_SPAM, "htmlize: reverse: $reverse\n"); - } elsif ($code eq "\003") { - $line =~ m/\003(\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; - } - debug (DEBUG_SPAM, "htmlize: c: $color; bgc: $bgcolor\n"); - } else { - $bold = 0; - $underline = 0; - $reverse = 0; - $color = 16; - $bgcolor = 16; - debug (DEBUG_SPAM, "htmlize: b: $bold; u: $underline; r $reverse; c: $color; bgc: $bgcolor\n"); - } - } #end foreach code - debug (DEBUG_SPAM, "htmlize: old tag: $tag\n"); - if ($tag =~ /<span style=.*>/) { - $tag = "</span>"; - } else { - $tag = ""; - } - 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]; " : "") - ); - debug (DEBUG_SPAM, "htmlize: css: $css\n"); - $tag .= "<span style=\"$css\">" if ($css ne ""); - debug (DEBUG_SPAM, "htmlize: new tag: $tag\n"); - $line =~ s/$block/$tag/; - } # end while blocks - $line .= "</span>" if ($tag =~ /<span style=.*>/); - $string .= $line . "</div>\n"; - } # end foreach lines - $string =~ s%(http|ftp)://[^\s\n<>]+%<a href="$&">$&</a>%g; - return $string; -} - # NUMBERIZE: Find all the word-based numbers in a string and replace them # with digit-based numbers. sub numberize { @@ -791,7 +709,7 @@ sub load { $chat_words{$rule[1]}{$rule[0]}[0] = $rule[2]; } close(RULES); - &debug(DEBUG_STD, "Rules loaded successfully!\n", DEBUG_NO_PREFIX); + &debug(DEBUG_STD, "Rules loaded successfully!\n"); $loaded = 1; &debug(DEBUG_STD, "Checking for lost words... "); @@ -963,6 +881,9 @@ sub plugin_register { # PLUGIN_CALLBACK: Calls the given plugin function with paramters. sub plugin_callback { + if(!defined $kernel) { + warn 'In plugin_callback before $kernel is defined'; + } my ($plugin, $function, @params) = @_; debug(DEBUG_SPAM, "Running callback to $function in $plugin.\n"); return &$function($kernel, @params); @@ -1789,6 +1710,10 @@ sub private_message { sub channel_message { my ($nick) = split(/!/, $_[ ARG0 ]); my ($channel, $text) = @_[ ARG1, ARG2 ]; + $text =~ s/\003\d{0,2},?\d{0,2}//g; + $text =~ s/[\002\017\026\037]//g; + + &debug(DEBUG_STD, "[@{$channel}:$nick] $text\n"); my $prefix = option('global', 'command_prefix'); my $nickmatch = "(" . $chosen_nick . "|" . @@ -1800,14 +1725,6 @@ sub channel_message { &plugin_callback($_, $event_channel_message{$_}, ($nick, $channel, 'SAY', $text)); } - # We pass the original string to plugins. Then, we strip out formatting - # codes. Who knows? Someone might want to log things exactly as they - # were. - $text =~ s/\003\d{0,2},?\d{0,2}//g; - $text =~ s/[\002\017\026\037]//g; - - &debug(DEBUG_STD, "[@{$channel}:$nick] $text\n"); - if ($text =~ /^\Q$prefix\E/) { my @command = split(/\s/, $text); my $cmd = $command[0]; @@ -1982,6 +1899,8 @@ sub initialize { $kernel->sig( USR1 => 'restart' ); $kernel->sig( USR2 => 'rehash' ); + $kernel->alias_set('simbot'); # so plugins can talk back to us + $kernel->post(bot => register => "all"); &irc_connect; @@ -2172,6 +2091,9 @@ sub quit_session { # remove any alarms. This stops any verbose output simbot was giving $kernel->alarm_remove_all( ); + + # remove our alias + $kernel->alias_remove('simbot'); $kernel->sig_handled(); } |
|
From: Pete P. <fou...@us...> - 2005-07-28 00:09:59
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21267/plugins Modified Files: httpd.pl Log Message: Closer to getting restart in the admin page working. Index: httpd.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/httpd.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -p -r1.7 -r1.8 --- httpd.pl 27 Jul 2005 22:20:54 -0000 1.7 +++ httpd.pl 28 Jul 2005 00:09:49 -0000 1.8 @@ -120,11 +120,10 @@ sub admin_page { if($request->uri =~ m|\?restart$|) { - &SimBot::debug(3, "Restart requested by web admin\n"); if(!defined $kernel) { warn "Trying to restart simbot without a kernel"; } - &SimBot::restart($kernel); + $kernel->post('simbot', 'restart', "web admin"); return; } elsif(my ($say) = $request->uri =~ m|\?say=(\S+)$|) { $say =~ s/\+/ /g; @@ -168,6 +167,7 @@ sub messup_httpd { sub cleanup_httpd { $kernel->call($aliases->{httpd}, 'shutdown'); + undef $aliases; } &SimBot::plugin_register( |
|
From: Pete P. <fou...@us...> - 2005-07-27 22:21:11
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25556 Modified Files: config.default.ini Log Message: Move the administration page's user/pass and the httpd's port to the config file Index: config.default.ini =================================================================== RCS file: /cvsroot/simbot/simbot/config.default.ini,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -p -r1.29 -r1.30 --- config.default.ini 18 Jul 2005 23:18:52 -0000 1.29 +++ config.default.ini 27 Jul 2005 22:20:55 -0000 1.30 @@ -221,5 +221,22 @@ lang=en # use commas for multiple, like default_zones=UTC,America/New_York default_zones=UTC +[plugin.httpd] +# port sets what port the web server should listen on. This probably +# should be 8000 or 80. The default is 8000. +port=8000 + +# admin_user sets the username for the administrative page. +# If not set or blank, the administrative page is unavailable. +# The default is unset. If set, must be 5 or more characters. +#admin_user=admin + +# admin_pass sets the password for the administrative page. +# If not set or blank, the administrative page is unavailable. +# The default is unset. If set, must be 5 or more characters. +# ### SECURITY WARNING: +# ### You should make sure the configuration file is not readable to other +# ### users! +#admin_pass= # End of Config |
|
From: Pete P. <fou...@us...> - 2005-07-27 22:21:11
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25556/plugins Modified Files: httpd.pl Log Message: Move the administration page's user/pass and the httpd's port to the config file Index: httpd.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/httpd.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -p -r1.6 -r1.7 --- httpd.pl 27 Jul 2005 22:09:52 -0000 1.6 +++ httpd.pl 27 Jul 2005 22:20:54 -0000 1.7 @@ -24,17 +24,15 @@ use POE; use POE::Component::Server::HTTP; use HTTP::Status; -use constant WEB_PORT => 8090; -use constant ADMIN_USER => 'admin'; -use constant ADMIN_PASS => 'hahaha'; - our $aliases; #our $kernel; use vars qw( $kernel ); $aliases = POE::Component::Server::HTTP->new( Alias => 'simbot_plugin_httpd', - Port => WEB_PORT, + Port => (defined &SimBot::option('plugin.httpd', 'port') + ? &SimBot::option('plugin.httpd', 'port') + : 8000), ContentHandler => { '/' => \&index_handler, }, @@ -100,14 +98,18 @@ EOT sub admin_page { my ($request, $response) = @_; + if(!defined &SimBot::option('plugin.httpd', 'admin_pass')) { + die "In admin_page with no password!"; + } + if(!defined $request->authorization_basic) { $response->www_authenticate('Basic realm="simbot admin"'); $response->code(RC_UNAUTHORIZED); return; } my ($user, $pass) = $request->authorization_basic; - if($user ne ADMIN_USER - || $pass ne ADMIN_PASS) { + if($user ne &SimBot::option('plugin.httpd', 'admin_user') + || $pass ne &SimBot::option('plugin.httpd', 'admin_pass')) { $response->www_authenticate = 'Basic realm="simbot admin"'; @@ -146,10 +148,17 @@ sub admin_page { sub messup_httpd { $kernel = $_[0]; - $SimBot::hash_plugin_httpd_pages{'admin'} = { - 'title' => 'SimBot Administration', - 'handler' => \&admin_page, - }; + + 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', + 'handler' => \&admin_page, + }; + } $SimBot::hash_plugin_httpd_pages{'fiveohoh'} = { 'title' => 'Internal Server Error Generation Department', |
|
From: Pete P. <fou...@us...> - 2005-07-27 22:10:02
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23118/plugins Modified Files: httpd.pl Log Message: Remote admin can now speak through SimBot. Enjoy ;-) If plugins don't provide a status code, a RC_OK (200) will be provided for them unless they fail to provide content, in which case we use RC_INTERNAL_SERVER_ERROR (500) and provide some content. Index: httpd.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/httpd.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- httpd.pl 27 Jul 2005 21:46:37 -0000 1.5 +++ httpd.pl 27 Jul 2005 22:09:52 -0000 1.6 @@ -32,7 +32,7 @@ our $aliases; #our $kernel; use vars qw( $kernel ); -$session = POE::Component::Server::HTTP->new( +$aliases = POE::Component::Server::HTTP->new( Alias => 'simbot_plugin_httpd', Port => WEB_PORT, ContentHandler => { @@ -54,6 +54,17 @@ sub index_handler { if(defined $SimBot::hash_plugin_httpd_pages{$req_root}) { my $handler = $SimBot::hash_plugin_httpd_pages{$req_root}->{'handler'}; &$handler($request, $response); + + if(!defined $response->content + || length $response->content == 0) { + # Hey! Our plugin didn't do anything useful. + $response->code(RC_INTERNAL_SERVER_ERROR); + $response->content("something's broken"); + # FIXME: We need error pages... + } elsif(!defined $response->code) { + $response->code(RC_OK); # assume everything's OK + } + return; } @@ -113,14 +124,23 @@ sub admin_page { } &SimBot::restart($kernel); return; - } elsif(my $say = $request->uri =~ m|\?say=(\S+)$|) { - $say =~ s/\+/ /; + } elsif(my ($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"); - # FIXME: send message + &SimBot::send_message(&SimBot::option('network', 'channel'), + $say); + } elsif(my ($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); } $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>'; + $response->code(RC_OK); $response->content($msg); } @@ -129,8 +149,12 @@ sub messup_httpd { $SimBot::hash_plugin_httpd_pages{'admin'} = { 'title' => 'SimBot Administration', 'handler' => \&admin_page, - } - #&add_page('/test', 'Goes nowhere, does nothing!', sub {}); + }; + + $SimBot::hash_plugin_httpd_pages{'fiveohoh'} = { + 'title' => 'Internal Server Error Generation Department', + 'handler' => sub {}, + }; } sub cleanup_httpd { |
|
From: Pete P. <fou...@us...> - 2005-07-27 21:46:46
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17680/plugins Modified Files: httpd.pl Log Message: Y'know, hitting save before committing works better. Index: httpd.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/httpd.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- httpd.pl 27 Jul 2005 21:39:26 -0000 1.4 +++ httpd.pl 27 Jul 2005 21:46:37 -0000 1.5 @@ -28,7 +28,9 @@ use constant WEB_PORT => 8090; use constant ADMIN_USER => 'admin'; use constant ADMIN_PASS => 'hahaha'; -use vars qw( $kernel $session ); +our $aliases; +#our $kernel; +use vars qw( $kernel ); $session = POE::Component::Server::HTTP->new( Alias => 'simbot_plugin_httpd', @@ -132,7 +134,7 @@ sub messup_httpd { } sub cleanup_httpd { - $session->call('shutdown'); + $kernel->call($aliases->{httpd}, 'shutdown'); } &SimBot::plugin_register( |
|
From: Pete P. <fou...@us...> - 2005-07-27 21:39:34
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15802/plugins Modified Files: httpd.pl Log Message: Beginnings of an administrative interface. No, it doesn't work. I need a valid $kernel, and I can't figure out why I'm not getting one. Index: httpd.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/httpd.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- httpd.pl 27 Jul 2005 17:37:18 -0000 1.3 +++ httpd.pl 27 Jul 2005 21:39:26 -0000 1.4 @@ -22,12 +22,15 @@ use strict; use POE; use POE::Component::Server::HTTP; +use HTTP::Status; use constant WEB_PORT => 8090; +use constant ADMIN_USER => 'admin'; +use constant ADMIN_PASS => 'hahaha'; -our $aliases; +use vars qw( $kernel $session ); -$aliases = POE::Component::Server::HTTP->new( +$session = POE::Component::Server::HTTP->new( Alias => 'simbot_plugin_httpd', Port => WEB_PORT, ContentHandler => { @@ -42,13 +45,12 @@ sub index_handler { # build and display a index of what is available my ($request, $response) = @_; - &SimBot::debug(3, 'httpd: handling request for ' . $request->uri . "\n"); + my ($req_root) = $request->uri =~ m|^http://.*?/([^/\?]*)|; - my $requested_page = $request->uri; - $requested_page =~ s|^http://(.*?)/|/|; + &SimBot::debug(3, 'httpd: handling request for ' . $request->uri . ", req root $req_root\n"); - if(defined $SimBot::hash_plugin_httpd_pages{$requested_page}) { - my $handler = $SimBot::hash_plugin_httpd_pages{$requested_page}->{'handler'}; + if(defined $SimBot::hash_plugin_httpd_pages{$req_root}) { + my $handler = $SimBot::hash_plugin_httpd_pages{$req_root}->{'handler'}; &$handler($request, $response); return; } @@ -82,16 +84,55 @@ EOT } +sub admin_page { + my ($request, $response) = @_; + + if(!defined $request->authorization_basic) { + $response->www_authenticate('Basic realm="simbot admin"'); + $response->code(RC_UNAUTHORIZED); + return; + } + my ($user, $pass) = $request->authorization_basic; + if($user ne ADMIN_USER + || $pass ne ADMIN_PASS) { + + $response->www_authenticate = + 'Basic realm="simbot admin"'; + $response->code(RC_UNAUTHORIZED); + return; + } + my $msg = &page_header('SimBot Admin'); + + + if($request->uri =~ m|\?restart$|) { + &SimBot::debug(3, "Restart requested by web admin\n"); + if(!defined $kernel) { + warn "Trying to restart simbot without a kernel"; + } + &SimBot::restart($kernel); + return; + } elsif(my $say = $request->uri =~ m|\?say=(\S+)$|) { + $say =~ s/\+/ /; + &SimBot::debug(3, "Speech requested by web admin\n"); + # FIXME: send message + } + $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>'; + $response->content($msg); +} + sub messup_httpd { - $SimBot::hash_plugin_httpd_pages{'/test'} = { - 'title' => 'Goes nowhere, does nothing!', - 'handler' => sub {}, + $kernel = $_[0]; + $SimBot::hash_plugin_httpd_pages{'admin'} = { + 'title' => 'SimBot Administration', + 'handler' => \&admin_page, } #&add_page('/test', 'Goes nowhere, does nothing!', sub {}); } sub cleanup_httpd { - POE::Kernel->call($aliases->{httpd}, 'shutdown'); + $session->call('shutdown'); } &SimBot::plugin_register( |
|
From: Kevin S. <ks...@us...> - 2005-07-27 17:37:27
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15100 Modified Files: simbot.pl Log Message: What exactly did I do? I stole some old code from a perl script I had written, then I totally rewrote it anyway. This adds htmlize, which converts IRC control codes into HTML for use with the httpd plugin. I made recap use it and output in HTML, and I don't know why CVS says httpd.pl has been changed. Index: simbot.pl =================================================================== RCS file: /cvsroot/simbot/simbot/simbot.pl,v retrieving revision 1.128 retrieving revision 1.129 diff -u -d -p -r1.128 -r1.129 --- simbot.pl 26 Jul 2005 01:52:20 -0000 1.128 +++ simbot.pl 27 Jul 2005 17:37:17 -0000 1.129 @@ -107,6 +107,11 @@ our %numbers_digits = (one => 1, two => six => 6, seven => 7, eight => 8, nine => 9, ); + +our @named_colors = ("white", "black", "navy", "green", "red", "maroon", + "purple", "orange", "yellow", "lightgreen", "teal", + "cyan", "blue", "magenta", "gray", "silver"); + # **************************************** # ************ Start of Script *********** # **************************************** @@ -490,6 +495,82 @@ sub parse_style { return $_; } +# HTMLIZE: Converts IRC color codes, links into HTML. +sub htmlize { + my @lines = split(/\n/, $_[0]); + my $string = ""; + foreach my $line (@lines) { + my $bold = 0; + my $reverse = 0; + my $underline = 0; + my $color = 16; + my $bgcolor = 16; + my $tag = ""; + $line =~ s/&/&/; + $line =~ s/>/>/; + $line =~ s/</</; + $line = "<div>" . $line; + while($line =~ m/[\002\003\017\026\037]+/) { + my $block = $&; + my @codes = split(//, $block); + debug (DEBUG_SPAM, "htmlize: codes: " . (@codes) . "\n"); + foreach my $code (@codes) { + if ($code eq "\002") { + $bold = 1 - $bold; + debug (DEBUG_SPAM, "htmlize: bold: $bold\n"); + } elsif ($code eq "\037") { + $underline = 1 - $underline; + debug (DEBUG_SPAM, "htmlize: underline: $underline\n"); + } elsif ($code eq "\026") { + $reverse = 1 - $reverse; + debug (DEBUG_SPAM, "htmlize: reverse: $reverse\n"); + } elsif ($code eq "\003") { + $line =~ m/\003(\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; + } + debug (DEBUG_SPAM, "htmlize: c: $color; bgc: $bgcolor\n"); + } else { + $bold = 0; + $underline = 0; + $reverse = 0; + $color = 16; + $bgcolor = 16; + debug (DEBUG_SPAM, "htmlize: b: $bold; u: $underline; r $reverse; c: $color; bgc: $bgcolor\n"); + } + } #end foreach code + debug (DEBUG_SPAM, "htmlize: old tag: $tag\n"); + if ($tag =~ /<span style=.*>/) { + $tag = "</span>"; + } else { + $tag = ""; + } + 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]; " : "") + ); + debug (DEBUG_SPAM, "htmlize: css: $css\n"); + $tag .= "<span style=\"$css\">" if ($css ne ""); + debug (DEBUG_SPAM, "htmlize: new tag: $tag\n"); + $line =~ s/$block/$tag/; + } # end while blocks + $line .= "</span>" if ($tag =~ /<span style=.*>/); + $string .= $line . "</div>\n"; + } # end foreach lines + $string =~ s%(http|ftp)://[^\s\n<>]+%<a href="$&">$&</a>%g; + return $string; +} + # NUMBERIZE: Find all the word-based numbers in a string and replace them # with digit-based numbers. sub numberize { @@ -710,7 +791,7 @@ sub load { $chat_words{$rule[1]}{$rule[0]}[0] = $rule[2]; } close(RULES); - &debug(DEBUG_STD, "Rules loaded successfully!\n"); + &debug(DEBUG_STD, "Rules loaded successfully!\n", DEBUG_NO_PREFIX); $loaded = 1; &debug(DEBUG_STD, "Checking for lost words... "); @@ -1708,10 +1789,6 @@ sub private_message { sub channel_message { my ($nick) = split(/!/, $_[ ARG0 ]); my ($channel, $text) = @_[ ARG1, ARG2 ]; - $text =~ s/\003\d{0,2},?\d{0,2}//g; - $text =~ s/[\002\017\026\037]//g; - - &debug(DEBUG_STD, "[@{$channel}:$nick] $text\n"); my $prefix = option('global', 'command_prefix'); my $nickmatch = "(" . $chosen_nick . "|" . @@ -1723,6 +1800,14 @@ sub channel_message { &plugin_callback($_, $event_channel_message{$_}, ($nick, $channel, 'SAY', $text)); } + # We pass the original string to plugins. Then, we strip out formatting + # codes. Who knows? Someone might want to log things exactly as they + # were. + $text =~ s/\003\d{0,2},?\d{0,2}//g; + $text =~ s/[\002\017\026\037]//g; + + &debug(DEBUG_STD, "[@{$channel}:$nick] $text\n"); + if ($text =~ /^\Q$prefix\E/) { my @command = split(/\s/, $text); my $cmd = $command[0]; |
|
From: Kevin S. <ks...@us...> - 2005-07-27 17:37:27
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15100/plugins Modified Files: httpd.pl recap.pl Log Message: What exactly did I do? I stole some old code from a perl script I had written, then I totally rewrote it anyway. This adds htmlize, which converts IRC control codes into HTML for use with the httpd plugin. I made recap use it and output in HTML, and I don't know why CVS says httpd.pl has been changed. Index: httpd.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/httpd.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- httpd.pl 27 Jul 2005 02:44:33 -0000 1.2 +++ httpd.pl 27 Jul 2005 17:37:18 -0000 1.3 @@ -98,4 +98,4 @@ sub cleanup_httpd { plugin_id => 'httpd', event_plugin_load => \&messup_httpd, event_plugin_unload => \&cleanup_httpd, -); \ No newline at end of file +); Index: recap.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/recap.pl,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -p -r1.17 -r1.18 --- recap.pl 27 Jul 2005 02:44:33 -0000 1.17 +++ recap.pl 27 Jul 2005 17:37:18 -0000 1.18 @@ -115,8 +115,8 @@ sub recap_page { my ($request, $response) = @_; # $response->code(RC_OK); - $response->push_header('Content-Type', 'text/plain'); - $response->content(join("\n", @backlog)); + $response->push_header("Content-Type", "text/html"); + $response->content(&SimBot::htmlize(join("\n", @backlog))); } # Register Plugin @@ -140,7 +140,7 @@ sub recap_page { event_channel_part => \&record_recap, event_server_nick => \&nick_change, ); - + $SimBot::hash_plugin_httpd_pages{'/recap'} = { 'title' => "Current Chatter", 'handler' => \&recap_page, |
|
From: Kevin S. <ks...@us...> - 2005-07-27 15:51:53
|
Update of /cvsroot/simbot/simbot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21562 Modified Files: INSTALL TODO Log Message: FourOhFour always picks the things at the /end/ of the TODO list to implement. I guess it's cause most of them were his ideas. :) Index: INSTALL =================================================================== RCS file: /cvsroot/simbot/simbot/INSTALL,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -p -r1.24 -r1.25 --- INSTALL 19 Jul 2005 12:29:28 -0000 1.24 +++ INSTALL 27 Jul 2005 13:44:26 -0000 1.25 @@ -53,7 +53,7 @@ intend to use any of the stock plugins p * Required by: dict -[ Text::Aspell] +[ Text::Aspell ] * Required by: aspell @@ -61,6 +61,10 @@ intend to use any of the stock plugins p * Required by: time +[ POE::Component::Server::HTTP ] + + * Required by: httpd + All of these modules are available in the CPAN repository, so you can install them in most Perl environments by running: Index: TODO =================================================================== RCS file: /cvsroot/simbot/simbot/TODO,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -p -r1.19 -r1.20 --- TODO 25 Jul 2005 09:34:10 -0000 1.19 +++ TODO 27 Jul 2005 13:44:26 -0000 1.20 @@ -30,7 +30,6 @@ Targets for Beyond 1.0 Wish List ====================== -- Integrated web server using POE::Component::Server::HTTP. - Implement authentication for bot administration. - Eventually recognize the possibility of joining 2 or more channels. - Allow for media other than IRC (connection plugins). |
|
From: Pete P. <fou...@us...> - 2005-07-27 02:44:41
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14874/plugins Modified Files: recap.pl httpd.pl Log Message: The web server works. Recap is now available over it. - httpd.pl still blocks simbot's quit. Just ^C it again after it disconnects. - Beautification will come later. As will configurability. - Why port 8090? 'cause 8080 was taken on my box. Index: recap.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/recap.pl,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -p -r1.16 -r1.17 --- recap.pl 4 May 2005 20:59:40 -0000 1.16 +++ recap.pl 27 Jul 2005 02:44:33 -0000 1.17 @@ -111,6 +111,14 @@ sub nick_change { record_recap($kernel, $nick, undef, "NICK", undef, $newnick); } +sub recap_page { + my ($request, $response) = @_; + +# $response->code(RC_OK); + $response->push_header('Content-Type', 'text/plain'); + $response->content(join("\n", @backlog)); +} + # Register Plugin &SimBot::plugin_register(plugin_id => "recap", plugin_params => "[<lines>]", @@ -132,3 +140,8 @@ sub nick_change { event_channel_part => \&record_recap, event_server_nick => \&nick_change, ); + +$SimBot::hash_plugin_httpd_pages{'/recap'} = { + 'title' => "Current Chatter", + 'handler' => \&recap_page, +} Index: httpd.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/httpd.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- httpd.pl 27 Jul 2005 02:02:33 -0000 1.1 +++ httpd.pl 27 Jul 2005 02:44:33 -0000 1.2 @@ -25,9 +25,9 @@ use POE::Component::Server::HTTP; use constant WEB_PORT => 8090; -our %pages; +our $aliases; -POE::Component::Server::HTTP->new( +$aliases = POE::Component::Server::HTTP->new( Alias => 'simbot_plugin_httpd', Port => WEB_PORT, ContentHandler => { @@ -47,16 +47,16 @@ sub index_handler { my $requested_page = $request->uri; $requested_page =~ s|^http://(.*?)/|/|; - if(defined $pages{$requested_page}) { - my $handler = $pages{$requested_page}->{'handler'}; + if(defined $SimBot::hash_plugin_httpd_pages{$requested_page}) { + my $handler = $SimBot::hash_plugin_httpd_pages{$requested_page}->{'handler'}; &$handler($request, $response); return; } my $msg = &page_header('SimBot'); $msg .= "<ul>\n"; - foreach my $url (keys %pages) { - my $title = $pages{$url}->{'title'}; + 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>\n); } @@ -82,24 +82,20 @@ EOT } -sub add_page { - my ($url, $title, $handler) = @_; - - &SimBot::debug(3, "httpd: adding page $url\n"); - - $pages{$url} = { - 'title' => $title, - 'handler' => $handler, - }; - - +sub messup_httpd { + $SimBot::hash_plugin_httpd_pages{'/test'} = { + 'title' => 'Goes nowhere, does nothing!', + 'handler' => sub {}, + } + #&add_page('/test', 'Goes nowhere, does nothing!', sub {}); } -sub messup_httpd { - &add_page('/test', 'Goes nowhere, does nothing!', sub {}); +sub cleanup_httpd { + POE::Kernel->call($aliases->{httpd}, 'shutdown'); } &SimBot::plugin_register( plugin_id => 'httpd', event_plugin_load => \&messup_httpd, + event_plugin_unload => \&cleanup_httpd, ); \ No newline at end of file |
|
From: Pete P. <fou...@us...> - 2005-07-27 02:02:48
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9282/plugins Added Files: httpd.pl Log Message: Beginnings of the HTTPD plugin. No, it doesn't do anything useful yet. --- NEW FILE: httpd.pl --- # SimBot HTTPD plugin # # 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 package SimBot::plugin::httpd; use warnings; use strict; use POE; use POE::Component::Server::HTTP; use constant WEB_PORT => 8090; our %pages; POE::Component::Server::HTTP->new( Alias => 'simbot_plugin_httpd', Port => WEB_PORT, ContentHandler => { '/' => \&index_handler, }, Headers => { Server => 'SimBot', }, ); sub index_handler { # build and display a index of what is available my ($request, $response) = @_; &SimBot::debug(3, 'httpd: handling request for ' . $request->uri . "\n"); my $requested_page = $request->uri; $requested_page =~ s|^http://(.*?)/|/|; if(defined $pages{$requested_page}) { my $handler = $pages{$requested_page}->{'handler'}; &$handler($request, $response); return; } my $msg = &page_header('SimBot'); $msg .= "<ul>\n"; foreach my $url (keys %pages) { my $title = $pages{$url}->{'title'}; $msg .= qq(<li><a href="$url">$title</a>\n); } $msg .= "</ul>\n"; $response->code(RC_OK); $response->push_header("Content-Type", "text/html"); $response->content($msg); } sub page_header { my ($title) = @_; return <<EOT; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <link rel="generator" href="http://simbot.sf.net/" /> <title>$title</title> </head> <body> EOT } sub add_page { my ($url, $title, $handler) = @_; &SimBot::debug(3, "httpd: adding page $url\n"); $pages{$url} = { 'title' => $title, 'handler' => $handler, }; } sub messup_httpd { &add_page('/test', 'Goes nowhere, does nothing!', sub {}); } &SimBot::plugin_register( plugin_id => 'httpd', event_plugin_load => \&messup_httpd, ); |
|
From: Kevin S. <ks...@us...> - 2005-07-26 02:12:26
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32752/plugins Modified Files: services.chanserv.pl Log Message: Better, but definitely not perfect Index: services.chanserv.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/services.chanserv.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -p -r1.11 -r1.12 --- services.chanserv.pl 26 Jul 2005 01:44:05 -0000 1.11 +++ services.chanserv.pl 26 Jul 2005 02:12:17 -0000 1.12 @@ -48,6 +48,17 @@ sub services_login { } } +sub registration_check { + my ($kernel, undef, undef, $newnick) = @_; + my $want = &SimBot::option('global', 'nickname'); + my $me = $SimBot::chosen_nick; + + if ($me eq $newnick && $me eq $want) { + &SimBot::debug(3, "Checking nickname availability...\n"); + $kernel->post(bot => sl => "nickserv info"); + } +} + # CHECK_RESPONSE: When we try to log in or run a command, services will tell us # something. Here, we handle different possible cases. sub check_response { @@ -182,9 +193,10 @@ sub process_notify { if ($me eq $want) { # Just check registration. Nickserv will let us know whether # we need to log in. - # XXX: This should be delayed. - $kernel->post(bot => sl => "nickserv info"); + # XXX: This should probably be delayed. + ®istration_check($kernel, undef, undef, $me); } else { + &SimBot::debug(3, "Desired nickname is in use; trying ghost...\n"); $kernel->post(bot => sl => "nickserv ghost $want $pass"); } } @@ -226,6 +238,7 @@ sub ban_user { event_channel_nojoin => \&request_unban, event_channel_mejoin => \&process_join, event_channel_novoice => \&request_voice, + event_server_nick => \®istration_check, list_nicks_ison => "NickServ", ); |