From 615ba66655a9d71018267b038ed34cdf23220b6d Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Wed, 12 Apr 2023 16:19:04 +0200 Subject: [PATCH] Add message to donate command --- plugins/unlisted | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/unlisted b/plugins/unlisted index 5888190..221cd7d 100644 --- a/plugins/unlisted +++ b/plugins/unlisted @@ -14,21 +14,21 @@ sub amount($self, $cart, $arg, @) { $self->{amount} = parse_amount($arg) or return REJECT, "Invalid amount."; if ($self->{command} eq 'donate') { - $cart - ->add(-$self->{amount}, "Donation (THANK YOU!)") - ->add_contra("+donations", +$self->{amount}, "Donation by \$you"); + return "Message ('x' for no message)", sub($self, $cart, $desc, @) { + $desc = $desc eq 'x' ? "" : " ($desc)"; + $cart + ->add(-$self->{amount}, "Donation$desc - THANK YOU!") + ->add_contra("+donations", +$self->{amount}, "Donation by \$you"); - return ACCEPT; + return ACCEPT; + } } - return "Please provide a short description", \&description; + return "Please provide a short description", sub($self, $cart, $desc, @) { + $cart + ->add(-$self->{amount}, "Unlisted: $desc") + ->add_contra("+sales/unlisted", +$self->{amount}, "Unlisted: $desc by \$you"); + + return ACCEPT; + }; } - -sub description($self, $cart, $desc, @) { - $cart - ->add(-$self->{amount}, "Unlisted: $desc") - ->add_contra("+sales/unlisted", +$self->{amount}, "Unlisted: $desc by \$you"); - - return ACCEPT; -} -