Update 'tool/irssi_cf_alturl.pl'

This commit is contained in:
unethical 2019-05-05 07:46:40 +00:00
parent a60e6598c0
commit da82749679
1 changed files with 7 additions and 2 deletions

View File

@ -130,7 +130,7 @@ sub GotUrl {
} }
} }
my ( $myurl, $fqdn, $junk ); my ( $myurl, $fqdn, $junk, $mytype );
my ( $url, $browser, $response, $answer ); my ( $url, $browser, $response, $answer );
my ( $line, $ifoundit ); my ( $line, $ifoundit );
@ -138,12 +138,14 @@ sub GotUrl {
$myurl = $_; $myurl = $_;
( $junk, $fqdn ) = split( /\/\//, $myurl, 2 ); ( $junk, $fqdn ) = split( /\/\//, $myurl, 2 );
( $fqdn, $junk ) = split( /\//, $fqdn, 2 ); ( $fqdn, $junk ) = split( /\//, $fqdn, 2 );
$mytype = '';
if ( length($fqdn) >= 4 ) { if ( length($fqdn) >= 4 ) {
## Start of Act ## Start of Act
## ACT1: Update URL if Cloudflared ## ACT1: Update URL if Cloudflared
if ( grep( /^$fqdn$/, @cached ) ) { if ( grep( /^$fqdn$/, @cached ) ) {
deb("$target Found in Cache $fqdn"); deb("$target Found in Cache $fqdn");
$mytype = '^B^K3[Archive^O] ';
$myurl = 'https://web.archive.org/web/' . $myurl; $myurl = 'https://web.archive.org/web/' . $myurl;
} }
else { else {
@ -163,6 +165,7 @@ sub GotUrl {
if ( $ifoundit == 1 ) { if ( $ifoundit == 1 ) {
push( @cached, $fqdn ); push( @cached, $fqdn );
$mytype = '^B^K3[Archive^O] ';
$myurl = 'https://web.archive.org/web/' . $myurl; $myurl = 'https://web.archive.org/web/' . $myurl;
} }
} }
@ -176,6 +179,7 @@ sub GotUrl {
$answer = $response->content; $answer = $response->content;
if ( $answer eq '[true,true]' ) { if ( $answer eq '[true,true]' ) {
push( @cached, $fqdn ); push( @cached, $fqdn );
$mytype = '^B^K3[Archive^O] ';
$myurl = 'https://web.archive.org/web/' . $myurl; $myurl = 'https://web.archive.org/web/' . $myurl;
} }
} }
@ -191,6 +195,7 @@ sub GotUrl {
$response = $browser->get($url); $response = $browser->get($url);
$answer = $response->content; $answer = $response->content;
if ( index( $answer, 'https://ux.nu/' ) == 0 ) { if ( index( $answer, 'https://ux.nu/' ) == 0 ) {
$mytype = '^B^K7[Short^O] ';
$myurl = $answer; $myurl = $answer;
} }
} }
@ -201,7 +206,7 @@ sub GotUrl {
$server->command("msg $target $myurl"); $server->command("msg $target $myurl");
} }
else { else {
$server->print( "$target", "$myurl", MSGLEVEL_CLIENTCRAP ); $server->print( "$target", "$mytype$myurl", MSGLEVEL_CLIENTCRAP );
} }
## End of Act ## End of Act
} }