From 3e49346bc5e718951f406e3b14ada6034b3ac5a6 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Wed, 2 Jan 2019 17:36:22 +0100 Subject: [PATCH] Add "donate" command --- plugins/unlisted | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/unlisted b/plugins/unlisted index cb100a1..1ef9964 100755 --- a/plugins/unlisted +++ b/plugins/unlisted @@ -2,15 +2,23 @@ HELP "unlisted" => "Buy unlisted product (manual entry)"; -sub command :Tab(unlisted) { +sub command :Tab(unlisted,donate) { my ($self, $cart, $command) = @_; - $command eq 'unlisted' or return NEXT; + $command eq 'unlisted' or $command eq 'donate' or return NEXT; + $self->{command} = $command; + return "Amount to deduct from your account", \&amount; } sub amount { my ($self, $cart, $arg) = @_; $self->{amount} = parse_amount($arg) or return REJECT, "Invalid amount."; + + if ($self->{command} eq 'donate') { + $cart->add(undef, -$self->{amount}, "Donation (THANK YOU!)"); + return ACCEPT; + } + return "Please provide a short description", \&description; }