Fixed option handling for servers and automatic URL catching
authorpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Wed, 12 Sep 2007 21:55:22 +0000 (21:55 +0000)
committerpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Wed, 12 Sep 2007 21:55:22 +0000 (21:55 +0000)
git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@28 088b83a4-0077-4247-935c-42ec02c2848b

irc.pl

diff --git a/irc.pl b/irc.pl
index 0d117c8..a175adf 100644 (file)
--- a/irc.pl
+++ b/irc.pl
@@ -32,9 +32,12 @@ sub new {
        $self->{ "nick" } = "Destult";
        $self->{ "port" } = 6667;
        $self->{ "password" } = "";
-       while( shift ) {
+       $self->{ "trap" } = 0;
+       while( $_ = shift ) {
+               print( "IRC : Parsing Option '$_'\n" );
                my( $name, $value ) = split( /=/, $_, 2 );
                if( exists( $self->{ $name } ) ) {
+                       print( "IRC : Setting $name to $value\n" );
                        $self->{ $name } = $value;
                }
        }
@@ -172,6 +175,11 @@ sub on_public {
        # Strip color
        $msg =~ s/(\x3)[0-9]{0,2}//g;
        $msg =~ s/\x02//g;
+       if( $msg =~ m!(http://[^[:space:]]+)!i && $self->{ "trap" } == 1 ) {
+               print( "IRC : URL Trapped: '$1' from $who\n" );
+               my $url = $1;
+               $kernel->post( "core", "cmd", $who, "TINYURL $url", $self->{ "ssid" }, $dest->[0], "send_public_to" );
+       }
        $cmd = ( split( / /, $msg, 2 ) )[0];
        $kernel->post( "core", "seen", $who, $msg, $self->{ "ssid" }, $who, "send_private" );
        if( $cmd =~ /^[~].*/ ) {