revbank/plugins/idle

29 lines
817 B
Perl

#!perl
my $timeout = 10;
sub hook_prompt_idle {
my ($class, $cart, $plugin, $seconds, $readline) = @_;
if ($seconds >= $timeout and $cart->size and not $plugin) {
call_hooks("beep");
return if $seconds > $timeout; # text only once
my $text = $readline->copy_text;
my $point = $readline->{point};
$readline->save_prompt;
$readline->replace_line("");
$readline->redisplay;
my $help = $cart->entries('refuse_checkout')
? "Enter 'abort' to abort."
: "Enter username to pay/finish or 'abort' to abort.";
print "\e[33;2;1mTransaction incomplete.\e[0m $help\n";
$readline->restore_prompt;
$readline->replace_line($text);
$readline->{point} = $point;
$readline->redisplay;
}
}