Hubot

 view release on metacpan or  search on metacpan

lib/Hubot/Scripts/shorten.pm  view on Meta::CPAN

                $bitly = $data->{data}{url};
            }

            $msg->http( $msg->match->[0] )->header( "User-Agent",
                "Mozilla/5.0 (X11; Linux x86_64; rv:10.0.7) Gecko/20100101 Firefox/10.0.7 Iceweasel/10.0.7"
                )->get(
                sub {
                    my ( $body, $hdr ) = @_;
                    return if ( !$body || !$hdr->{Status} =~ /^2/ );

                    ## content-type
                    my @ct = split( /\s*,\s*/, $hdr->{'content-type'} );
                    if ( grep {/^image\/.+$/i} @ct || grep { !/text/i } @ct ) {
                        return $msg->send("[$ct[0]] - $bitly");
                    }

                    ### charset
                    ### <meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
                    ### [FILTER] - <script type="text/javascript" src="http://news.chosun.com/dhtm/js/gnb_news_2011.js" charset="euc-kr"></script>
                    $body =~ s{\r\n}{\n}g;
                    my @charset_lines
                        = grep { $_ !~ /script/ } grep {/charset/} split /\n/,



( run in 0.412 second using v1.01-cache-2.11-cpan-524268b4103 )