my( $time, $how, $message ) = split( / /, $what, 3 );
my( $prot, $type, $targ ) = split( /:/, $how, 3 );
$time = int( $time );
- if( exists( $heap->{ 'identified' }->{ uc( $who ) } ) ) {
- if( length( $what ) > 0 && $time >= 0 ) {
- if( $message ) {
- if( !exists( $heap->{ 'ads' } ) ) {
- $heap->{ 'ads' } = [];
- }
- my $ad = scalar( @{ $heap->{ 'ads' } } );
- $heap->{ 'ads' }->[ $ad ] = [ $time, $prot, $type, $targ, $message ];
- $kernel->delay_set( "advertise", $time, $ad );
- $kernel->post( $src, $replypath, "$who: Advert added as #".$ad, $dest );
- } else {
- if( exists( $heap->{ 'ads' }->[ $time ] ) ) {
- $kernel->post( $src, $replypath, "$who: Ad disabled.", $dest );
- print( "ADVERTISE: Ad #".$time." disabled.\n" );
- $heap->{ 'ads' }->[ $time ]->[0] = -1;
- } else {
- $kernel->post( $src, $replypath, "$who: Ad #".$time." not found.", $dest );
- print( "ADVERTISE: Ad #".$time." not found.\n" );
- }
+ if( length( $what ) > 0 && $time >= 0 ) {
+ if( $message ) {
+ if( !exists( $heap->{ 'ads' } ) ) {
+ $heap->{ 'ads' } = [];
}
+ my $ad = scalar( @{ $heap->{ 'ads' } } );
+ $heap->{ 'ads' }->[ $ad ] = [ $time, $prot, $type, $targ, $message ];
+ $kernel->delay_set( "advertise", $time, $ad );
+ $kernel->post( $src, $replypath, "$who: Advert added as #".$ad, $dest );
} else {
- $kernel->post( $src, $replypath, "Usage: ADVERTISE <period> <outputmodule>:<outputmethod>:<outputtarget> <message>", $dest );
- $kernel->post( $src, $replypath, "Ex. : ADVERTISE 3600 mod_irc:send_public_to:#dc Hourly Advertisement", $dest );
- if( exists( $heap->{ 'ads' } ) ) {
- $kernel->post( $src, $replypath, "Current advertisements:", $dest );
- my $i = 0;
- for( @{ $heap->{ 'ads' } } ) {
- my( $period, $prot, $type, $targ, $message ) = @{ $_ };
- $kernel->post( $src, $replypath, "$i: ($period) -> $prot:$type:$targ : $message", $dest );
- $i++;
- }
+ if( exists( $heap->{ 'ads' }->[ $time ] ) ) {
+ $kernel->post( $src, $replypath, "$who: Ad disabled.", $dest );
+ print( "ADVERTISE: Ad #".$time." disabled.\n" );
+ $heap->{ 'ads' }->[ $time ]->[0] = -1;
+ } else {
+ $kernel->post( $src, $replypath, "$who: Ad #".$time." not found.", $dest );
+ print( "ADVERTISE: Ad #".$time." not found.\n" );
}
}
} else {
- $kernel->post( $src, $replypath, "'Advertise' is restricted to identified users.", $dest );
+ $kernel->post( $src, $replypath, "Usage: ADVERTISE <period> <outputmodule>:<outputmethod>:<outputtarget> <message>", $dest );
+ $kernel->post( $src, $replypath, "Ex. : ADVERTISE 3600 mod_irc:send_public_to:#dc Hourly Advertisement", $dest );
+ if( exists( $heap->{ 'ads' } ) ) {
+ $kernel->post( $src, $replypath, "Current advertisements:", $dest );
+ my $i = 0;
+ for( @{ $heap->{ 'ads' } } ) {
+ my( $period, $prot, $type, $targ, $message ) = @{ $_ };
+ $kernel->post( $src, $replypath, "$i: ($period) -> $prot:$type:$targ : $message", $dest );
+ $i++;
+ }
+ }
}
}