About this snippet
Overview
My first time using sockets. Used to shorten urls using is.gd
Credit Swiftirc forums for the socket tutorial I followed.
Credit Swiftirc forums for the socket tutorial I followed.
alias shorten {
if (sock(isgd)) {
sockclose isgd
sockopen isgd is.gd 80
set %isgd $$1
}
else {
sockopen isgd is.gd 80
set %isgd $$1
}
}
on *:sockopen:isgd:{
sockwrite -nt $sockname GET /api.php?longurl= $+ %isgd HTTP/1.1
sockwrite -nt $sockname Host: is.gd
sockwrite -nt $sockname $crlf
}
on *:sockread:isgd:{
sockread %temp
if (http://is.gd/* iswm %temp) {
echo -a Shortened URL: %temp
}
}
menu Menubar {
Shorten URL: /shorten $$?="URL to Shorten?"
}
