- enhance _default() debugging function
authorAndreas Scherbaum <andreas@scherbaum.biz>
Fri, 20 Jan 2012 21:24:25 +0000 (22:24 +0100)
committerAndreas Scherbaum <andreas@scherbaum.biz>
Fri, 20 Jan 2012 21:24:25 +0000 (22:24 +0100)
- get rid of many unnecessary output

docbot.pl

index 423ecfeb86a59c52873d7104f0dce3610d267f6b..87b36d8e8834b1d7a79b0f04aaafab0b9922f708 100755 (executable)
--- 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;
+}