AutoMagic URL Shorten-er™ (using

By TheImrac on May 01, 2012

Made a quick script to automatically shorten URLs on input.

I used Fuzionx usage of Chessnut's $getsource script.

Here is a link to Fuzionx:
And Chessnut's $getsource script

This uses COMs so you must have them enabled. The script should be pretty dang quick even with multiple URLs in a single message.

You can turn it off by right clicking the channel or query window, or you can use an exclamation point in front of your message.

Let me know if anyone has issues with URL's not being caught or if other things are accidentally caught.

; Version 1.0.2
; Fixed regex color stripper

; Version 1.0.1
; - Fixed regex boo-boo

;Version 1.0.0
; - Initial Release

; // Our alias that attempts to shorten and return the URL past  //
; // based on Fuzionx "URL Shortern" Script (hawkee) //
; // Also Based on Chessnuts $getsource script (unknown) //
alias {
  var %longURL = $1
  var = shorten. $+ $ticks
  .comopen msxml2.xmlhttp
  noop $com(,OPEN,1,bstr,POST,bstr, $+ $iif($goo.gl_api,?key= $+ $v1),bool,false)
  noop $com(,setRequestHeader,1,bstr,Content-Type,bstr,application/json)
  noop $com(,Send,1,bstr,$+($chr(123),"longUrl": $qt(%longURL),$chr(125)))
  noop $com(,ResponseText,2)
  var %fullresult = $com(
  if ($regex(%fullresult,/"id": "(.*?)"/)) { return $regml(1) }
  else {
    echo -q 5 An Error occured while shorting $1
    return %longURL
alias -l goo.gl_api { return AIzaSyDMl5272dQj965CkWUqlqZBnTFWMW9BiE0 }

; // Helper Aliases to catch and attempt to shorten input url  //
alias -l url-regex { return /(?<=^| )((?:(?:ht|f)tps?:[/][/])?(?:www\.|[\w\d\.]+\.|(?=[\w\d]+\.(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|tv|co|tk)))[\w\d]+\.[\w]{2,3}(?:[/]\S*)?)/giS }
alias short.input {
  if (!$regex($1-,/^[/!]/s)) {
    say $regsubex(url,$1-,$url-regex,$ \t ))

menu channel,query {
  Auto URL Short
  .On:.enable #shortener
  .Off:.disable #shortener

; // And of course our input events //
#shortener on
on *:input:?:{ short.input $1- }
on *:input:#:{ short.input $1- }
#shortener end


Sign in to comment.
dma   -  May 17, 2015

this goes in remote?

chorao   -  Nov 30, 2012

Using... :)

TheImrac   -  May 02, 2012

Nice find!! Thanks!

Firstmate   -  May 02, 2012

This is where I remember seeing his script a long time ago.

Nice script by the way.

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.