use Digest::MD5 qw( md5_hex );
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
my( $whom, $password );
- print( "IDENTIFY: $who for ***** from $src to $dest via $replypath\n" );
+ print( "IDENTIFY: $who for ***** from $src to ".$dest->{ "dest" }." via $replypath\n" );
my @array = split( / /, $what );
if( scalar( @array ) > 1 ) {
DEFINE: |-
sub {
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
- print( "DEFINE: $who for $what from $src to $dest via $replypath\n" );
+ print( "DEFINE: $who for $what from $src to ".$dest->{ "dest" }." via $replypath\n" );
my( $subj, $predicate ) = split( / as /, $what, 2 );
if( $subj ) {
if( $predicate ) {
APPEND: |-
sub {
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
- print( "APPEND: $who for $what from $src to $dest via $replypath\n" );
+ print( "APPEND: $who for $what from $src to ".$dest->{ "dest" }." via $replypath\n" );
my( $subj, $predicate ) = split( / with /, $what, 2 );
if( exists( $heap->{ 'db' }->{ uc( $subj ) } ) ) {
if( length( $predicate ) > 0 ) {
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' ) {
LITERAL: |-
sub {
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
- print( "LITERAL: $who for $what from $src to $dest via $replypath\n" );
+ print( "LITERAL: $who for $what from $src to ".$dest->{ "dest" }." via $replypath\n" );
if( exists( $heap->{ 'db' }->{ uc( $what ) } ) ) {
$kernel->post( "$src", $replypath, "$what is ".$heap->{ 'db' }->{ uc( $what ) }, $dest );
} else {
ADVERTISE: |-
sub {
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
- print( "ADVERTISE: $who for $what from $src to $dest via $replypath\n" );
+ print( "ADVERTISE: $who for $what from $src to ".$dest->{ "dest" }." via $replypath\n" );
my( $time, $how, $message ) = split( / /, $what, 3 );
my( $prot, $type, $targ ) = split( /:/, $how, 3 );
$time = int( $time );
$kernel->post( $src, $replypath, $arr[2]." [first: ".$arr[0]."/".$arr[1]."]", $dest );
} else {
my $url = makeashorterlink( $what ) or return;
- $heap->{ 'urls' }->{ uc( $what ) } = [ $who, $dest, $url ];
+ $heap->{ 'urls' }->{ uc( $what ) } = [ $who, $dest->{ 'text' }, $url ];
$kernel->post( $src, $replypath, "$url [$who]", $dest );
}
}
print( "CORE: <$who> $cmd -- $subj\n" ) unless( !exists $Destult::config{ 'DEBUG' } );
my $noparse = 0;
+ my $no_throttle = 0;
+ $cmd =~ s/^@\+/+@/;
if( substr( $cmd, 0, 1 ) eq "+" ) {
$noparse = 1;
$cmd = substr( $cmd, 1 );
}
+ if( substr( $cmd, 0, 1 ) eq "@" ) {
+ $no_throttle = 1;
+ $cmd = substr( $cmd, 1 );
+ }
if( exists( $heap->{ 'commands' }->{ uc( $cmd ) } ) ) {
if( !exists $heap->{ 'cmdaccess' }->{ uc( $cmd ) } ||
$heap->{ 'cmdaccess' }->{ uc( $cmd ) } == 0 || (
exists $heap->{ 'identified' }->{ $src.uc( $who ) } &&
accessLevel( $kernel, $heap, uc( $who ), $src ) >= $heap->{ 'cmdaccess' }->{ uc( $cmd ) } ) ) {
- &{ $heap->{ 'commands' }->{ uc( $cmd ) } }( $kernel, $heap, $who, $subj, $src, $dest, $replypath );
+ &{ $heap->{ 'commands' }->{ uc( $cmd ) } }( $kernel, $heap, $who, $subj, $src, { dest => $dest, src=>$who, no_throttle => $no_throttle }, $replypath );
} else {
- $kernel->post( $src, $replypath, "$who: An access level of ".$heap->{ 'cmdaccess' }->{ uc( $cmd ) }." is required for '$cmd'", $dest );
+ $kernel->post( $src, $replypath, "$who: An access level of ".$heap->{ 'cmdaccess' }->{ uc( $cmd ) }." is required for '$cmd'", { dest=>$dest, src=>$who, no_throttle=>$no_throttle } );
}
} elsif( exists( $heap->{ 'db' }->{ uc( $what ) } ) && !$noparse ) {
- &{ $heap->{ 'commands' }->{ 'PARSE' } }( $kernel, $heap, $who, $what, $src, $dest, $replypath );
+ &{ $heap->{ 'commands' }->{ 'PARSE' } }( $kernel, $heap, $who, $what, $src, { dest => $dest, src=>$who, no_throttle => $no_throttle }, $replypath );
} else {
$kernel->post( $src, "send_private", "Huh?", $who );
}
$self->{ "port" } = 6667;
$self->{ "password" } = "";
$self->{ "trap" } = 0;
+ $self->{ "throttle" } = 0;
while( $_ = shift ) {
print( "IRC : Parsing Option '$_'\n" );
my( $name, $value ) = split( /=/, $_, 2 );
my( $kernel, $heap, $msg ) = @_[ KERNEL, HEAP, ARG0 ];
for my $chan (split( /,/, $self->{ "channel" } ) ) {
$chan = (split( /:/, $chan ))[0];
- $kernel->yield( "send_public_to", $msg, $chan );
+ $kernel->yield( "send_public_to", $msg, { dest=>$chan, no_throttle=>1 } );
}
}
sub send_public_to {
my( $kernel, $heap, $msg, $target ) = @_[ KERNEL, HEAP, ARG0, ARG1 ];
- if( $target =~ /^[#&][a-zA-Z0-9-_]+$/ ) {
- print( "IRC : =>$target: $msg\n" );
- local( $Text::Wrap::columns = 354 );
- my @msg = split( /\n/, wrap( '', '', $msg ) );
- for( @msg ) {
- $kernel->post( $heap->{ 'ircobject' }->session_id(), "privmsg", $target, $_ );
+ use Data::Dumper;
+ my $self = $heap->{ "self" };
+ my $no_throttle = $target->{ "no_throttle" };
+ print(
+ "n_t: ".$no_throttle."\n".
+ "s-t: ".$self->{ "throttle" }."\n".
+ "len: ".length($msg)."\n" );
+ if( $target->{ "dest" } =~ /^[#&][a-zA-Z0-9-_]+$/ ) {
+ if( $no_throttle || !$self->{ "throttle" } || length $msg <= 354 ) {
+ print( "IRC : =>".$target->{ "dest" }.": $msg\n" );
+ local( $Text::Wrap::columns = 354 );
+ my @msg = split( /\n/, wrap( '', '', $msg ) );
+ for( @msg ) {
+ $kernel->post( $heap->{ 'ircobject' }->session_id(), "privmsg", $target->{ "dest" }, $_ );
+ }
+ } else {
+ $kernel->yield( "send_private", $msg, { dest=>$target->{ "src" }, src=>$target->{ "src" } } );
}
} else {
- print( "IRC : Could not send '$msg' to '$target' -- '$target' is not a channel\n" );
+ print( "IRC : Could not send '$msg' to '".$target->{ "dest" }."' -- '".$target->{ "dest" }."' is not a channel\n" );
}
}
sub send_private {
my( $kernel, $heap, $msg, $who ) = @_[ KERNEL, HEAP, ARG0, ARG1 ];
- my $nick = ( split( /!/, $target, 2 ) )[0];
local( $Text::Wrap::columns = 354 );
my @msg = split( /\n/, wrap( '', '', $msg ) );
for( @msg ) {
- $kernel->post( $heap->{ 'ircobject' }->session_id(), "notice", $who, $_ );
+ $kernel->post( $heap->{ 'ircobject' }->session_id(), "notice", $who->{ "dest" }, $_ );
}
}