New plugin: market
Hackerspace members sell their surplus components, space profits.
This commit is contained in:
parent
b3e2dd9a68
commit
7321b99c6b
3 changed files with 41 additions and 0 deletions
35
plugins/market
Executable file
35
plugins/market
Executable file
|
@ -0,0 +1,35 @@
|
||||||
|
#!perl
|
||||||
|
|
||||||
|
HELP "market" => "Edit market list";
|
||||||
|
|
||||||
|
my $filename = 'revbank.market';
|
||||||
|
|
||||||
|
sub command :Tab(market) {
|
||||||
|
my ($self, $cart, $command) = @_;
|
||||||
|
|
||||||
|
if ($command eq 'market') {
|
||||||
|
system $ENV{EDITOR} || 'vi', $filename;
|
||||||
|
return ACCEPT;
|
||||||
|
}
|
||||||
|
|
||||||
|
my @products;
|
||||||
|
|
||||||
|
open my $fh, '<', $filename or die $!;
|
||||||
|
/\S/ && !/^\s*#/ and push @products, [split " ", $_, 5] while readline $fh;
|
||||||
|
chomp @$_ for @products;
|
||||||
|
|
||||||
|
for my $fields (@products) {
|
||||||
|
my ($username, $id, $seller, $space, $description) = @$fields;
|
||||||
|
|
||||||
|
next if $command ne $id;
|
||||||
|
next if $space < 0;
|
||||||
|
next if $seller < 0;
|
||||||
|
|
||||||
|
$cart->add(undef, -($seller + $space), $description);
|
||||||
|
$cart->add($username, 0+$seller, "\$you bought $description")
|
||||||
|
if 0+$seller;
|
||||||
|
return ACCEPT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NEXT;
|
||||||
|
}
|
5
revbank.market
Normal file
5
revbank.market
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Price =
|
||||||
|
# Seller Barcode Seller + Space Description
|
||||||
|
|
||||||
|
Juerd sku81873 6.00 2.00 Cijfertjes/ledjes/knopjes-module
|
||||||
|
|
|
@ -14,6 +14,7 @@ take
|
||||||
# Then, plugins that apply heuristics
|
# Then, plugins that apply heuristics
|
||||||
|
|
||||||
products # matches product IDs (barcodes)
|
products # matches product IDs (barcodes)
|
||||||
|
market # also matches product IDs
|
||||||
withdraw # matches amounts
|
withdraw # matches amounts
|
||||||
users # matches usernames
|
users # matches usernames
|
||||||
deposit # wants to be after 'users'
|
deposit # wants to be after 'users'
|
||||||
|
|
Loading…
Add table
Reference in a new issue