From 9ad6cb03da1f17e03c735ba19939bef017a322e3 Mon Sep 17 00:00:00 2001 From: pdbogen Date: Mon, 25 Aug 2008 16:44:43 +0000 Subject: [PATCH] Plenty of bugs. Or paper. Whatever. Change response messages from DEFINE git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@54 088b83a4-0077-4247-935c-42ec02c2848b --- commands.yaml | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/commands.yaml b/commands.yaml index 13584e3..44336ca 100644 --- a/commands.yaml +++ b/commands.yaml @@ -329,11 +329,11 @@ DEFINE: |- if( $predicate ) { $heap->{ 'db' }->{ uc( $subj ) } = $predicate; DumpFile( "factoids.yaml", $heap->{ 'db' } ); - $kernel->post( $src, $replypath, "Okay, $who.", $dest ); + $kernel->post( $src, $replypath, "$who: Factoid '$subj' defined as '$predicate'", $dest ); } else { delete $heap->{ 'db' }->{ uc( $subj ) } if exists $heap->{ 'db' }->{ uc( $subj ) }; DumpFile( "factoids.yaml", $heap->{ 'db' } ); - $kernel->post( $src, $replypath, "Okay, $who.", $dest ); + $kernel->post( $src, $replypath, "$who: Factoid '$subj' removed", $dest ); } } else { $kernel->post( $src, $replypath, "Invalid subject.", $dest ); @@ -1478,18 +1478,16 @@ SHORTEN: |- sub { my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_; my( $service, $url ) = split( / /, $what, 2 ); - $service =~ s/[^a-z]//gi; - if( length $url ) { - eval "use WWW::Shorten::$service"; - if( $@ ) { - $kernel->post( $src, $replypath, "Loading 'WWW::Shorten::$service' failed: $@", $dest ); - return; - } - } else { + if( ! length $url ) { $url = $service; - use WWW::Shorten::TinyURL; + $service = "SnipURL"; + } + $service =~ s/[^a-z]//gi; + eval "use WWW::Shorten::$service"; + if( $@ ) { + $kernel->post( $src, $replypath, "Loading 'WWW::Shorten::$service' failed: $@", $dest ); + return; } - my( $kernel, $heap, $who, $url, $src, $dest, $replypath ) = @_; if( !exists( $heap->{ 'urls' } ) ) { $heap->{ 'urls' } = {}; } @@ -1497,9 +1495,13 @@ SHORTEN: |- my @arr = @{ $heap->{ 'urls' }->{ uc( $url ) } }; $kernel->post( $src, $replypath, $arr[2]." [first: ".$arr[0]."/".$arr[1]."]", $dest ); } else { - my $url = makeashorterlink( $url ) or return; - $heap->{ 'urls' }->{ uc( $url ) } = [ $who, $dest->{ 'dest' }, $url ]; - $kernel->post( $src, $replypath, "$url [$who]", $dest ); + my $url = makeashorterlink( $url ); + if( defined $url ) { + $heap->{ 'urls' }->{ uc( $url ) } = [ $who, $dest->{ 'dest' }, $url ]; + $kernel->post( $src, $replypath, "$url [$who]", $dest ); + } else { + $kernel->post( $src, $replypath, "Shortening URL failed.", $dest ); + } } } FLUSHURLS: |- -- 2.11.0