Skip to content
TG007 community snippet #49

is.gd URL Shortener

My first time using sockets. Used to shorten urls using is.gd Credit Swiftirc forums for the socket tutorial I followed.

By sugarboy Added Dec 18, 2010 Updated Dec 18, 2010
General IRC All snippets
mIRC script 25 lines
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.
Source code

mIRC script

25 lines · 521 characters
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?"
}
Community

Comments

Want to join the discussion? Sign in to TG007.
FanfareFriday, 7 January, 2011
[code]if (sock(isgd)) { sockclose isgd } sockopen isgd is.gd 80 set %isgd $$1 } }[/code]No else condition is needed. [code] var %temp sockread %temp[/code]So that you don't have the data set as a global var in your variable.
sugarboySaturday, 18 December, 2010
Thank you err0r. This was my very first try with sockets. I have searched for something like it in the pass, but never found anything. So I figured it would be something to try for my first attempt. Actually quite proud of myself. ^__^
err0rSaturday, 18 December, 2010
nice snippet