Jethro commented on a Page, Simple URL Shortener  -  Nov 14, 2010

HeartBrokenTR, here is the code edited to be automated in detecting any URL entered in the channel and have it converted as a shortened version:

on *:text:*:#:lop $1-
on *:action:*:#:lop $1-
on *:notice:*:#:lop $1-
alias -l lop {
  if !%tc {
    inc -u4 %tc
    if $sock(lop) { sockclose lop }
    if $regex($1-,/((\w{3,8}\72\/\/)?(w{3}\56.+|\w+(?=\.\w{2,6})))/iS) {
      sockopen lop www.l0p.us 80
      sockmark lop # $regml(1) 
    }
  }
}
on *:sockopen:lop:{
  if $sockerr {
    .msg $token($sock(lop).mark,2,32) * ERROR: $sock(lop).wsmsg
  }
  else {
    var %sockmark $token($sock(lop).mark,2,32), %lop sockwrite -n lop
    %lop GET $+(/api-make.php?alias=&url=,%sockmark) HTTP/1.1
    %lop Host: www.l0p.us $+ $str($crlf,2)
  }
}
on *:sockread:lop:{
  var %read, %x $token($sock(lop).mark,1,32), %y $token($sock(lop).mark,2,32)
  sockread %read
  if http:// isin %read {
    .msg %x Shortened URL for $+(",%y,") is: $v2
  }
}

It'll also work for text, action and notice.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.