DumpFile( "karma.yaml", $heap->{ 'karma' } );
}
+KARMACLEAN: |-
+ sub {
+ my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+ if( !exists( $heap->{ "karma" } ) ) {
+ if( -e "karma.yaml" ) {
+ $heap->{ "karma" } = LoadFile( "karma.yaml" );
+ } else {
+ $kernel->post( $src, $replypath, "Karma has begun anew.", $dest );
+ return;
+ }
+ }
+ for my $k( keys %{ $heap->{ "karma" } } ) {
+ if( $k =~ /[[:space:]]/ ) {
+ delete $heap->{ "karma" }->{ $k };
+ }
+ }
+ $kernel->post( $src, $replypath, "Squeak squeak.", $dest );
+ DumpFile( "karma.yaml", $heap->{ 'karma' } );
+ }
+
KARMA: |-
sub {
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
my $mult = ($1 eq "-"?-1:1);
my @response;
my %karma = %{ $heap->{ "karma" } };
-
+
for( my $i = 0; $i < $target; $i++ ) {
push @response, [0,""];
}
}
}
}
- @response = sort { $a->[0] <=> $b->[0] } @response;
+ if( $mult == 1 ) {
+ @response = sort { $b->[0] <=> $a->[0] } @response;
+ } else {
+ @response = sort { $a->[0] <=> $b->[0] } @response;
+ }
my $resp = $response[0]->[1]." (".$response[0]->[0].")";
for( my $i = 1; $i < scalar @response; $i++ ) {
$resp .= ", ".$response[ $i ]->[1]." (".$response[ $i ]->[0].")";