$heap->{ 'cmdaccess' }->{ uc( $cmd ) } = $level;
DumpFile( "cmdaccess.yaml", $heap->{ 'cmdaccess' } );
$kernel->post( $src, $replypath, "Set.", $dest );
+ } elsif( exists( $heap->{ 'db' }->{ uc( $cmd ) } ) ) {
+ $heap->{ 'factoidAccess' } = {} unless exists $heap->{ 'factoidAccess' };
+ $heap->{ 'factoidAccess' }->{ uc( $cmd ) } = $level;
+ DumpFile( 'factoidAccess.yaml', $heap->{ 'factoidAccess' } );
+ $kernel->post( $src, $replypath, "Set.", $dest );
} else {
$kernel->post( $src, $replypath, "'$cmd' not found.", $dest );
}
}
+DECLASSIFY: |-
+ sub {
+ my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+ my %lists = (
+ 'cmdaccess' => 'command',
+ 'factoidAccess' => 'factoid',
+ );
+ my $found = 0;
+ for my $list (keys %lists) {
+ if( exists( $heap->{ $list } ) && exists( $heap->{ $list }->{ uc( $what ) } ) ) {
+ delete( $heap->{ $list }->{ uc( $what ) } );
+ $kernel->post( $src, $replypath, "'$what' removed from ".$lists{ $list }." access list.", $dest );
+ $found = 1;
+ }
+ }
+ if( !$found ) {
+ $kernel->post( $src, $replypath, "'$what' not found in any access lists.", $dest );
+ }
+ }
ACCESSLIST: |-
sub {
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
}
}
+RELOADCOMMANDS: |-
+ sub {
+ my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+ if( -e "commands.yaml" ) {
+ my %source = %{ LoadFile( "commands.yaml" ) };
+ for my $key ( keys %source ) {
+ print( "CORE: Parsing $key..." );
+ $heap->{ 'commands' }->{ $key } = eval( $source{ $key } );
+ if( $@ ) {
+ print( "FAILED: $@\n\n" );
+ delete $heap->{ 'commands' }->{ $key };
+ } else {
+ print( "Done.\n" );
+ }
+ }
+ $kernel->post( $src, $replypath, "Commands reloaded.", $dest );
+ } else {
+ $kernel->post( $src, $replypath, "No commands file found.", $dest );
+ }
+ }
+
+OPME: |-
+ sub {
+ my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+ $kernel->post( $src, "do_mode", $dest, "+o $who" );
+ }
+
+UNIDENTIFY: |-
+ sub {
+ my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+ if( exists( $heap->{ 'identified' } ) && exists( $heap->{ 'identified' }->{ $src.uc( $who ) } ) ) {
+ delete $heap->{ 'identified' }->{ $src.uc( $who ) };
+ $kernel->post( $src, $replypath, "$who: Identification cancelled.", $dest );
+ } else {
+ $kernel->post( $src, $replypath, "$who: You are not identified.", $dest );
+ }
+ }
IDENTIFY: |-
sub {
use Digest::MD5 qw( md5_hex );
PARSE: |-
sub {
+ use YAML qw(LoadFile DumpFile);
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
print( "PARSE: $who for $what from $src to $dest via $replypath\n" );
print( "PARSE: $what is ".$heap->{ 'db' }->{ uc( $what ) }."\n" );
+
+ if( !exists( $heap->{ 'factoidAccess' } ) && -e 'factoidAccess.yaml' ) {
+ $heap->{ 'factoidAccess' } = LoadFile( 'factoidAccess.yaml' );
+ }
+
+ if( exists( $heap->{ 'factoidAccess' }->{ uc( $what ) } ) &&
+ ( !exists( $heap->{ 'identified' }->{ $src.uc( $who ) } ) ||
+ accessLevel( $kernel, $heap, uc( $who ), $src ) < $heap->{ 'factoidAccess' }->{ uc( $what ) } ) ) {
+ $kernel->post( $src, $replypath, "$who: An access level of ".$heap->{ 'factoidAccess' }->{ uc( $what ) }." is required for the factoid '$what'", $dest );
+ return;
+ }
+
my( $response, $author ) = split( / -- /, $heap->{ 'db' }->{ uc( $what ) } );
if( $author ) {
$author = " -- ".$author;