From 489f34a53ad3323f134d6e8ea03ecf3bb9f0cb26 Mon Sep 17 00:00:00 2001 From: Andreas Scherbaum Date: Fri, 20 Jan 2012 22:24:25 +0100 Subject: [PATCH] - enhance _default() debugging function - get rid of many unnecessary output --- docbot.pl | 228 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 119 insertions(+), 109 deletions(-) diff --git a/docbot.pl b/docbot.pl index 423ecfe..87b36d8 100755 --- a/docbot.pl +++ b/docbot.pl @@ -1544,115 +1544,6 @@ sub do_autoping { } - - -## http://poe.perl.org/?POE_Cookbook/IRC_Bot_Debugging -## http://poe.perl.org/?POE_Cookbook/IRC_Bot_Disconnecting -## http://poe.perl.org/?POE_Cookbook/IRC_Bot_Reconnecting -## http://poe.perl.org/?POE_Cookbook -## http://poe.perl.org/?Tutorials -## http://poe.perl.org/?POE_Support_Resources -## http://www.mirc.net/raws/ - -# we registered for all events, this will produce some debug info. -sub _default { - -#foreach my $tmp (@_) { -# print "_default: $tmp\n"; -#} -#exit(); - - my ($sender, $event, $args) = @_[SENDER, ARG0 .. $#_]; - my @output = ( "$event: " ); - -##print "sender:\n" . Dumper($sender) . "\n"; -#print "class: " . $sender . "\n"; -#print "event: " . $event . "\n"; -#exit(); - -if (substr($event, 0, 1) eq '_') { - return; -} - - my $irc = $sender->get_heap(); - my $session = find_irc_session($irc); - - set_session_activity($session); - - - for my $arg (@$args) { - if ( ref($arg) eq 'ARRAY' ) { - push( @output, '[' . join(', ', @$arg ) . ']' ); - } elsif ( ref($arg) eq 'HASH' ) { - push( @output, '[' . '(hash)' . ']' ); - } else { - push ( @output, "'$arg'" ); - } - } - my $output = join(' ', @output); - - - - my $print_it = 1; - if ($event eq "autoping") { - $print_it = 0; - } - if ($event eq "irc_ping") { - $print_it = 0; - } - if ($event eq "irc_connected") { - $print_it = 0; - } - if ($event eq "irc_snotice") { - $print_it = 0; - } - if ($event eq "irc_whois") { - $print_it = 0; - } - if ($event eq "irc_mode") { - $print_it = 0; - } - if ($event eq "irc_topic") { - $print_it = 0; - } - if ($event eq "irc_ctcp_action") { - $print_it = 0; - } - if ($event eq "irc_notice") { - if (@$args[0] =~ /^NickServ/) { - $print_it = 0; - } - if (@$args[0] =~ /^ChanServ/) { - $print_it = 0; - } - } - if ($event eq "irc_ctcp_version") { - if (@$args[0] =~ /^freenode\-connect/) { - $print_it = 0; - } - } - if ($event =~ /^irc_\d+/) { - $print_it = 0; - } - $print_it = 1; - - - - if ($main::debug_traffic == 1) { - print $output . "\n"; - } - if ($print_it == 1) { - print_msg($output, DEBUG); - } - - send_to_commandchannel($output); - - - # don't handle signals - return 0; -} - - # on_nickused() # # called if the desired nick is already in use @@ -1807,6 +1698,125 @@ sub on_quit { } +## http://poe.perl.org/?POE_Cookbook/IRC_Bot_Debugging +## http://poe.perl.org/?POE_Cookbook/IRC_Bot_Disconnecting +## http://poe.perl.org/?POE_Cookbook/IRC_Bot_Reconnecting +## http://poe.perl.org/?POE_Cookbook +## http://poe.perl.org/?Tutorials +## http://poe.perl.org/?POE_Support_Resources +## http://www.mirc.net/raws/ + +# we registered for all events, this will produce some debug info. +sub _default { + +#foreach my $tmp (@_) { +# print "_default: $tmp\n"; +#} +#exit(); + + my ($sender, $event, $args) = @_[SENDER, ARG0 .. $#_]; + my @output = ( "$event: " ); + +##print "sender:\n" . Dumper($sender) . "\n"; +#print "class: " . $sender . "\n"; +#print "event: " . $event . "\n"; +#exit(); + +if (substr($event, 0, 1) eq '_') { + return; +} + + my $irc = $sender->get_heap(); + my $session = find_irc_session($irc); + + set_session_activity($session); + + + for my $arg (@$args) { + if ( ref($arg) eq 'ARRAY' ) { + push( @output, '[' . join(', ', @$arg ) . ']' ); + } elsif ( ref($arg) eq 'HASH' ) { + push( @output, '[' . '(hash)' . ']' ); + } else { + push ( @output, "'$arg'" ); + } + } + my $output = join(' ', @output); + + + my $print_it = 1; + if ($event eq "autoping") { + $print_it = 0; + } + if ($event eq "irc_ping") { + $print_it = 0; + } + if ($event eq "irc_pong") { + $print_it = 0; + } + if ($event eq "irc_connected") { + $print_it = 0; + } + if ($event eq "irc_snotice") { + $print_it = 0; + } + if ($event eq "irc_whois") { + $print_it = 0; + } + if ($event eq "irc_mode") { + $print_it = 0; + } + if ($event eq "irc_topic") { + $print_it = 0; + } + if ($event eq "irc_ctcp_action") { + $print_it = 0; + } + if ($event eq "irc_ctcp") { + $print_it = 0; + } + if ($event eq "irc_raw") { + $print_it = 0; + } + if ($event eq "irc_raw_out") { + $print_it = 0; + } + if ($event eq "irc_isupport") { + $print_it = 0; + } + if ($event eq "irc_notice") { + if (@$args[0] =~ /^NickServ/) { + $print_it = 0; + } + if (@$args[0] =~ /^ChanServ/) { + $print_it = 0; + } + if (@$args[0] =~ /\.freenode\.net/i) { + $print_it = 0; + } + } + if ($event eq "irc_ctcp_version") { + if (@$args[0] =~ /^freenode\-connect/) { + $print_it = 0; + } + } + if ($event =~ /^irc_\d+/) { + $print_it = 0; + } + #$print_it = 1; + + + if ($main::debug_traffic == 1) { + print $output . "\n"; + } + if ($print_it == 1) { + print_msg($output, DEBUG); + send_to_commandchannel($output); + } + + # don't handle POE signals + return 0; +} -- 2.39.5