All the credits of this snippets goes to the original poster: Daveoh, and the original work can be found here: http://www.hawkee.com/snippet/2041/
I edited it with wildcard for automatically catch every url on the chan and convert it into a tinyurl. You can think this edit is useless, but on my chan is really appreciated.
I've removed all triggers, and of course need to loaded on a bot.
Cheers
essebi
on *:TEXT:*http*:*:{
if (%tinyspam) { halt }
if (*http://tinyurl* iswm $1-) { halt }
set -u3 %tinyspam 1
set %tinyurlchan $chan
var %tinytemp $1-
set %tinyurl1 $wildtok(%tinytemp,http*,1,32)
if ($sock(tinyurl)) { sockclose tinyurl }
sockopen tinyurl tinyurl.com 80
}
alias tinyurl {
set -u3 %tinyspam 1
set %tinyurl1 $1
if ($sock(tinyurl)) { sockclose tinyurl }
sockopen tinyurl tinyurl.com 80
}
on *:sockopen:tinyurl:{
sockwrite -n $sockname GET /create.php?url= $+ %tinyurl1 HTTP/1.0
sockwrite -n $sockname Host: tinyurl.com
sockwrite -n $sockname user-agent: Mozilla/??
sockwrite -n $sockname Connection: Keep-Alive
sockwrite -n $sockname $crlf
}
on 1:sockread:tinyurl:{
:nextread
if ($sockerr > 0) return
sockread %temp
if ($sockbr == 0) return
if (<blockquote><b>* iswm %temp && $left($replace(%tinyurl1,&,&),15) !isin %temp) {
set %tinyurl2 $remove($gettok(%temp,2,60),b>)
if (%tinyurlchan) { msg %tinyurlchan %tinyurl2 }
else { echo -a Accorciato in %tinyurl2 }
unset %tinyurl*
}
goto nextread
}