- catch irc notice messages and output them to the command channel
authorAndreas Scherbaum <andreas@scherbaum.biz>
Fri, 3 Feb 2012 00:28:06 +0000 (01:28 +0100)
committerAndreas Scherbaum <andreas@scherbaum.biz>
Fri, 3 Feb 2012 00:28:06 +0000 (01:28 +0100)
docbot.pl

index f73fe6afb8f6546eb772567b60bb9809028ad7b7..ae8420f59797f6ca6f1b4debbe2eeccbea678851 100755 (executable)
--- a/docbot.pl
+++ b/docbot.pl
@@ -170,6 +170,7 @@ foreach my $session (keys(%main::sessions)) {
             irc_join         => \&on_join,
             irc_part         => \&on_part,
             irc_quit         => \&on_quit,
+            irc_notice       => \&on_irc_notice,
             irc_ping         => \&on_ping,
             autoping         => \&do_autoping,
             irc_error        => \&on_error,
@@ -2039,6 +2040,32 @@ sub on_irc_raw_out {
 }
 
 
+# on_irc_notice()
+#
+# output irc notices to commandchannel
+#
+sub on_irc_notice {
+    my ($sender, $kernel, $heap, $who, $notice) = @_[SENDER, KERNEL, HEAP, ARG0, ARG2];
+
+    my $nick = ( split /!/, $who )[0];
+    my $irc = $sender->get_heap();
+    my $session = find_irc_session($irc);
+
+    switch ($notice) {
+        case(/^NickServ/) {}
+        case(/^ChanServ/) {}
+        case(/\.freenode\.net/i) {}
+        else {
+            # send to commandchannel
+            my $text = 'irc notice on session ' . $irc->nick_name() . ' from: ' . $nick;
+            send_to_commandchannel($text);
+            $text = 'text: ' . $notice;
+            send_to_commandchannel($text);
+        }
+    }
+}
+
+
 ## 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