tglogo.png

Downloading File

Filename: TinyURL
/*
**
** Created by: Rand (@DALnet)
** Script name: Tinyurl - v1.0
**
**     Description:
**
**       This script allows you to take a long url,
**       and create a short one via the use of tinyurl.com
**
**
**     Useage:
**
**        /tinyurl [-s] [url]
**
**        *  The -s switch is optional, uses /say, instead of /echo.
**
**        *  The url is also optional, if you do not specify one it
**           will do one of the following, in this order:
**           *  Check the clipboard for a URL
**           *  Check to see if $url is filled (meaning your browser is open)
**           *  If both of the above conditions are filled, then it'll ask you
**              which you want to use.
**
*/
alias tinyurl { turl $1 }
alias turl {
  if ($1 == -s) { hadd -m tinyurl disp say | tokenize 32 $2- }
  else { hadd -m tinyurl disp echo -a Url: }

  if (!$1) {
    var %url1 = $regex($cb(1),/^http:\S+$/)
    var %urlcb = $gettok($cb(1),1,32) , %url = $url
    if (%url1 && %url) {
      if ($input(Use clipboard instead of browser url?,y,Which url to use:)) {
        tokenize 32 %urlcb
      }
      else { tokenize 32 %url }
    }
    elseif (%urlcb) { tokenize 32 %urlcb }
    elseif (%url) { tokenize 32 $url }
    else {
      echo -a Tinyurl: Error. $&
        You need to specify a url, or have one in your clipboard, $&
        or have your browser open to the page you want to use.
    }
  }

  if ($sock(tinyurl)) { sockclose tinyurl }
  sockopen tinyurl www.tinyurl.com 80
  sockmark tinyurl $1
}

on *:sockopen:tinyurl:{
  var %% = sockwrite -n $sockname
  if ($sock($sockname).status != active) {
    echo -a *** Tinyurl: failed to connect to tinyurl.com
    hfree tinyurl | return
  }
  %% GET /create.php?url= $+ $sock($sockname).mark HTTP/1.0
  %% Host: tinyurl.com
  %% User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
  %%
}
on *:sockread:tinyurl:{
  var %s | sockread %s
  if ($regex(%s,/<blockquote><b>(.{7}tinyurl\.com.*?)<\/b><br><small>\[.*?\]<\/small><\/blockquote>/Si)) {
    $hget(tinyurl,disp) $regml(1)
  }
}
on *:sockclose:tinyurl:{ hfree tinyurl }

Related Files

by Soul_Eater
by Zmodem
by mountaindew

Please note that on our website we use cookies necessary for the functioning of our website, cookies that optimize the performance. To learn more about our cookies, how we use them and their benefits, please read our Cookie Policy.
I Understand