sub {
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
my $reply = "The following factoids were found: ";
- foreach( keys( %{ $heap->{ 'db' } } ) ) {
- $reply .= "'$_' ";
+ my @keys = keys( %{ $heap->{ 'db' } } );
+ @keys = sort @keys;
+ foreach( @keys ) {
+ if( length( $what ) > 0 && m/^$what/i ) {
+ $reply .= "'$_' ";
+ }
}
$kernel->post( $src, $replypath, $reply, $dest );
}
$heap->{ 'urls' } = {};
$kernel->post( $src, $replypath, "URL cache flushed.", $dest );
}
+GETLINE: |-
+ sub {
+ use LWP::Simple;
+ my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+ if( length( $what ) == 0 ) {
+ $kernel->post( $src, $replypath, "Usage: GETLINE <URL>", $dest );
+ return;
+ }
+ my $text = get( $what );
+ if( !$text ) {
+ $kernel->post( $src, $replypath, "Failed to retrieve URL.", $dest );
+ return;
+ }
+ $kernel->post( $src, $replypath, substr( $text, 0, 354 ), $dest );
+ }