
Undoes 714b337
because github seems to no longer require chmod +x
for syntax highlighting extensionless files.
49 lines
1.2 KiB
Perl
49 lines
1.2 KiB
Perl
#!perl
|
|
|
|
HELP "give <account> <amount> [<reason>]" => "Transfer money to user's account";
|
|
|
|
sub command :Tab(give) {
|
|
my ($self, $cart, $command) = @_;
|
|
|
|
return NEXT if $command ne 'give';
|
|
|
|
return "Benificiary", \&benificiary;
|
|
}
|
|
|
|
sub benificiary :Tab(USERS) {
|
|
my ($self, $cart, $input) = @_;
|
|
|
|
$self->{benificiary} = parse_user($input)
|
|
or return REJECT, "$input: No such user.";
|
|
|
|
return "Amount to give to $self->{benificiary}", \&amount;
|
|
}
|
|
|
|
sub amount {
|
|
my ($self, $cart, $input) = @_;
|
|
|
|
$self->{amount} = parse_amount($input)
|
|
or return REJECT, "$input: Invalid amount.";
|
|
|
|
return sprintf(
|
|
"Why are you giving %.2f to %s, or enter your username to end",
|
|
$self->{amount},
|
|
$self->{benificiary}
|
|
), \&reason;
|
|
}
|
|
|
|
sub reason :Tab(whatevah) {
|
|
my ($self, $cart, $input) = @_;
|
|
|
|
my $benificiary = $self->{benificiary};
|
|
my $amount = $self->{amount};
|
|
|
|
my $user = parse_user($input);
|
|
my $reason = $user ? "" : " ($input)";
|
|
|
|
$cart->add(undef, -$amount, "Given to $benificiary" . $reason);
|
|
$cart->add($benificiary, +$amount, "Received from \$you" . $reason);
|
|
$cart->checkout($user) if $user;
|
|
|
|
return ACCEPT;
|
|
}
|