X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=lib%2FSpeak.pm;h=7003f209803a5a186724907d9886e909e1ed534e;hb=38d55f066c8a0b870321c6a375ae1d78607dded5;hp=0869ed4aecae2d48e86f7b162849d342ddaca5a2;hpb=ded8d315fd3f6c050f759865b09f053ae85e52a5;p=clearscm.git diff --git a/lib/Speak.pm b/lib/Speak.pm index 0869ed4..7003f20 100644 --- a/lib/Speak.pm +++ b/lib/Speak.pm @@ -47,6 +47,7 @@ use warnings; use base 'Exporter'; use FindBin; +use Clipboard; use lib "$FindBin::Bin/../lib"; @@ -102,16 +103,20 @@ Returns: =cut - if (-f "$FindBin::Bin/shh") { + if (-f "$FindBin::Bin/../data/shh") { + $msg .= ' [silent shh]'; if ($log) { - $log->msg("Not speaking because we were asked to be quiet - $msg"); + $log->msg($msg); } else { - verbose "Not speaking because we were asked to be quiet - $msg"; + verbose $msg; } # if return; } # if + # Handle the case where $msg is not passed in. Then use the clipboard; + $msg = Clipboard->paste unless $msg; + # Handle the case where $msg is a filehandle $msg = <$msg> if ref $msg eq 'GLOB'; @@ -119,10 +124,12 @@ Returns: # backoff a little and try again. my $attempts = 0; my $maxretries = 3; - my $backoff = 2; my ($status, @output); + # Log message to log file if $log was passed in. + $log->msg($msg) if $log; + while ($attempts++ < $maxretries) { ($status, @output) = Execute "/usr/local/bin/gt \"$msg\""; @@ -135,9 +142,9 @@ Returns: error $errmsg; } # if - sleep $backoff++; + sleep int rand 10; } else { - return; # We said our piece... + return; } # if } # while