revbank/plugins/idle
2024-11-27 02:49:20 +01:00

36 lines
895 B
Perl

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