[SimBot-commits] CVS: simbot/plugins recap.pl,1.16,1.17 httpd.pl,1.1,1.2
Status: Abandoned
Brought to you by:
kstange
|
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 |