alias ip {
sockopen whatismyip whatismyip.com 80
echo socket opening
}
on *:sockopen:whatismyip: {
echo socket opened
sockwrite -n $sockname GET / HTTP/1.0
sockwrite -n $sockname Host: whatismyip.com $+ $crlf $+ $crlf
echo socket written
}
on *:sockread:whatismyip: {
echo socket reading
echo checking for errors
if ( $sockerr ) { echo -a Error while requesting IP: $sock($sockname).wmsg | halt }
else {
echo no errors, continuing
var %temptext
sockread %temptext
echo var temptext: " $+ %temptext $+ "
if ( <TITLE>Your ip is *.*.*.* WhatIsMyIP.com</TITLE> iswm %temptext ) {
echo -a Your IP is: $htmlfree(%temptext)
}
}
sockclose $sockname
echo socket closed
}
alias htmlfree {
echo filtering html
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
return %x
}