A simple URL shortener using the ou.gd service
on *:TEXT:!ougd *:#: {
sockClose ougd
%ougd.url = $2
%ougd.chan = $chan
SockOpen ougd ou.gd 80
}
on *:SockOpen:ougd: {
sockwrite -nt ougd GET $+(/api.php?format=simple&action=shorturl&url=,%ougd.url) PHP/5.3.3-7
sockwrite -n ougd Host: ou.gd
sockwrite -n ougd $crlf
}
on *:SockRead:ougd: {
var %ougd.read
sockRead -nf 20 %ougd.read
;echo 9 -ta %ougd.read
if (http://* iswm %ougd.read) {
msg %ougd.chan Shortened URL: %ougd.read
echo 9 -ta Shortened URL: %ougd.read
unset %ougd.*
}
}
That website's default support is the POST method, but you've used the GET...which in turn will work as well. :p
One thing you should be aware of is that if $2 is not a URL but something else, it may trigger the script to set the variables. You may need to make sure the $2 is a link.
You're encouraged to check up on the command /sockmark and the identifier $sock().mark so you don't have to set variables to be referenced.
Other than that, nice exertion you've made into this socket script.