Henco, nice work. I agree with Gummo and Sean that you should have used the sockmark command instead of the global var. There are a couple of overlooked considerations:
1) Make sure the $2 entered is a URL, not something else.
2) you should add a trigger protection to it to safeguard the client running the code to not get flooded.
Here is the improved version of your script:
on $*:text:/^!url\s((\w{3,8}\72\/\/)?(w{3}\56.+))/iS:#:{
if !%tc { inc -u4 %tc | if $sock(lop) { sockclose lop }
sockopen lop www.l0p.us 80 | sockmark lop $chan $regml(1) }
}
on *:sockopen:lop:{
var %sockmark $gettok($sock(lop).mark,2,32)
sockwrite -n lop GET $+(/api-make.php?alias=&url=,%sockmark) HTTP/1.1
sockwrite -n lop Host: www.l0p.us $+ $str($crlf,2)
}
on *:sockread:lop:{
var %read | sockread %read
if http:// isin %read { .msg $gettok($sock(lop).mark,1,32) Shortened URL: $v2 }
}