Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added inline debug print routine

_print_debug was great for the default routines, but there wasn't a suitable
routine for defined states.  Added one.
  • Loading branch information...
commit 9410a9f0b797657ca814c0908ba8dba715882331 1 parent bcd3f85
@an0maly an0maly authored
Showing with 33 additions and 0 deletions.
  1. +33 −0 radicalweed.pl
View
33 radicalweed.pl
@@ -59,6 +59,8 @@
my $channel = ref $where ? $where->[0] : $where;
$channel =~ s/^#//;
+ _inline_debug( 'irc_mode', @_[ ARG0 .. $#_ ] );
+
# See if we have op privileges before we go gallivanting about
# attempting to give +op and ticking off the server
@@ -82,6 +84,8 @@
my $channel = ref $where ? $where->[0] : $where;
$channel =~ s/^#//;
+ _inline_debug( 'irc_mode', @_[ ARG0 .. $#_ ] );
+
if( defined $towhom && $towhom eq $server->{nick} ) {
if( $what eq '+o' ) {
# I just received op privileges
@@ -102,6 +106,8 @@
my ( $sender, $what, $message ) = @_[ ARG0 .. ARG2 ];
my $i = 0;
+ _inline_debug( 'irc_mode', @_[ ARG0 .. $#_ ] );
+
if( $sender =~ /NickServ/i && $message =~ /This nickname is registered/ ) {
# do we have a password for our nick for this server?
@@ -163,3 +169,30 @@ sub _print_debug {
print join ' ', @output, "\n";
return 0;
}
+
+sub _inline_debug {
+ my ( $event, @args ) = @_;
+
+ return 0; # disable debugging
+
+ # skip logging events we don't care about
+ return 0 if grep /^$event$/, qw( irc_ping irc_372 );
+
+ # format the rest
+ my @output = ("$event: ");
+
+ for my $arg (@args) {
+ if ( ref $arg eq 'ARRAY' ) {
+ push( @output, '[' . join( ', ', @$arg ) . ']' );
+
+ }
+ else {
+ push( @output, "'$arg'" );
+
+ }
+
+ }
+ print join ' ', @output, "\n";
+ return 0;
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.