"give" now takes a reason like "take", only optional args between [] in help.

Contributed by BugBlue
This commit is contained in:
Juerd Waalboer 2013-02-28 16:31:05 +01:00
parent 7b088cb175
commit 6372e30cac
4 changed files with 22 additions and 7 deletions

View file

@ -2,7 +2,7 @@
# This plugin must at the end in the plugins file.
HELP "deposit [<amount>]" => "[Create and] deposit into an account";
HELP "deposit <amount>" => "[Create and] deposit into an account";
sub command :Tab(deposit) {
my ($self, $cart, $command) = @_;

View file

@ -1,6 +1,6 @@
#!perl
HELP "give [<account> [<amount>]]" => "Transfer money to user's account";
HELP "give <account> <amount> [<reason>]" => "Transfer money to user's account";
sub command :Tab(give) {
my ($self, $cart, $command) = @_;
@ -22,13 +22,28 @@ sub benedinges :Tab(USERS) {
sub amount {
my ($self, $cart, $input) = @_;
my $amount = parse_amount($input)
$self->{amount} = parse_amount($input)
or return REJECT, "$input: Invalid amount.";
my $user = $self->{user};
my $amount = $self->{amount};
$cart->add(undef, -$amount, "Given to $user");
$cart->add($user, +$amount, "Received from \$you");
return "Why are you giving $amount to $user, or enter your username to end",
\&reason;
}
sub reason :Tab(whatevah) {
my ($self, $cart, $input) = @_;
my $user = $self->{user};
my $amount = $self->{amount};
if ($user = parse_user($input)) {
$cart->add(undef, -$amount, "Given to $user");
$cart->add($user, +$amount, "Received from \$you");
$cart->checkout($input);
} else {
$cart->add(undef, -$amount, "Given to $user ($input)");
$cart->add($user, +$amount, "Received from \$you ($input)");
}
return ACCEPT;
}

View file

@ -1,6 +1,6 @@
#!perl
HELP "take [<accounts> [<amount>]]" => "Take money from users (equal parts)";
HELP "take <accounts> <amount> <reason>"=>"Take money from users (equal parts)";
sub command :Tab(take,steal) {
my ($self, $cart, $command) = @_;

View file

@ -1,6 +1,6 @@
#!perl
HELP "undo [<id>]" => "Undo a certain transaction";
HELP "undo <id>" => "Undo a certain transaction";
my $filename = ".revbank.undo";