Tuly URL Shortner

By TweakUniverse on Oct 20, 2010

Here you can use http://tuly.in in your irc chat. Just do !url http://site.com. Note: You must include the http:// IT IS VERY IMPORTANT YOU DO!!!

# ALL CREDIT GOES TO HENCO FOR MAKING THE SCRIPT :) #
on *:SockOpen:tuly: {
  sockwrite -nt tuly GET $+(/bm.php?url=,%Tuly.url) HTTP/1.1
  sockwrite -n tuly Host: www.tuly.in
  sockwrite -n tuly $crlf
}
on *:SockRead:tuly: {
  var %read | sockRead  %read
  if (http://* iswm %read) {
    .msg %Tuly.chan Shortened URL: %read
    unset %Tuly.*
  }
}
on *:text:!url *:#: {
  set %Tuly.chan $chan
  set %Tuly.url $2
  sockClose tuly
  sockOpen tuly www.tuly.in 80
}

Comments

Sign in to comment.
TweakUniverse   -  Oct 20, 2010

hmm thanks for that, i'll look at that tommo anyways (12:00pm here :p). I'm working on a beta for tuly.in which well soon include custom alias.

 Respond  
napa182   -  Oct 20, 2010

you could do it like this so you can do away with the global vars..

on $*:text:/^@url\s(http\x3A\/\/w{3}\x2E\S+\x2E\S{2,3}?\S+)/iS:#:{
  if ($sock(tuly)) sockclose tuly
  sockopen tuly www.tuly.in 80 
  sockmark tuly $+(/bm.php?url=,$regml(1)) msg # Shortened URL:
}
on *:sockopen:tuly: {
  sockwrite -n tuly GET $gettok($sock(tuly).mark,1,32) HTTP/1.1
  sockwrite -n tuly Host: $+($sock(tuly).addr,$str($crlf,2))
}
on *:sockread:tuly: {
  var %tuly | sockRead %tuly
  if ($regex(%tuly,/(http:\/\/.+)/)) { 
    $gettok($sock(tuly).mark,2-,32) $regml(1)
    sockclose tuly
  }
}

output is the same as the one you posted

Shortened URL: http://tuly.in/lYmBjY

you can also use the post method

on $*:text:/^@tuly\s(http\x3A\/\/w{3}\x2E\S+\x2E\S{2,3}?\S+)/iS:#:{  
  if ($sock(tuly)) sockclose tuly
  sockopen tuly tuly.in 80 
  sockmark tuly $regml(1) msg # Shortened URL:
}
on *:sockopen:tuly:{ 
  var %tuly $+(url=,$gettok($sock(tuly).mark,1,32),&submit=Shorten)
  sockwrite -n tuly POST /process.php HTTP/1.1 
  sockwrite -n tuly Host: $sock(tuly).addr 
  sockwrite -n tuly Content-Type: application/x-www-form-urlencoded 
  sockwrite -n tuly Content-Length: $len(%tuly) 
  sockwrite -n tuly $+($crlf,%tuly)
}
on *:sockread:tuly: { 
  var %tuly | sockread %tuly
  if ($regex(%tuly,/<.+value='(http.+?)'><\/h2>/)) { 
    $gettok($sock(tuly).mark,2-,32) $regml(1)
  }
}

the output looks like this

Shortened URL: http://tuly.in/lLwNaW

 Respond  
TweakUniverse   -  Oct 20, 2010

I made it from scratch, thanks also. The api was just added as well on that link :D The reason why i said the credit goes to henco is because it was his mirc script, i just altered it a bit. He didn't mind at all :D

 Respond  
napa182   -  Oct 20, 2010

Is that ur site?, cuz that mirc socket is on http://api.tuly.in/
anyways nice lil site

 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.