Bitly url shortener

By FordLawnmower on Nov 29, 2009

Script was requested by Luke on irc.geekshed.net
Simple URL shortener for your bot.
You must turn this on from the right click channel or status menu. Under bitly, click trigger on.
Syntax is !bitly http://link.name
There is a ! trigger to notice the user and a @ trigger to message the channel. The @ trigger requires halfops or higher to use.

There is also an alias that can be typed from the client the script is loaded into.
Syntax /echobitly http://link.name.here

Example output:
17:09:51 @bitly http://pastebin.com/m63db9ac2
17:09:54 <+RingKing Searching Bitly .......
17:09:54 <+RingKing Bitly » http://bit.ly/7S3RJ7

;Bitly Url Shortener by Ford_Lawnmower irc.mindforge.org #USA-Chat
menu Channel,Status {
  .$iif($group(#Bitly) == On,$style(1)) Bitly Trigger
  ..$iif($group(#Bitly) == On,$style(2)) On: .enable #Bitly
  ..$iif($group(#Bitly) == Off,$style(2)) Off: .disable #Bitly
}
#Bitly off
On $*:Text:/^(!|@)Bitly.*/Si:#: {
  if ($timer($+(Bitly,$network,$nick))) { return }
  .timer $+ $+(Bitly,$network,$nick) 1 6 noop
  var %method $iif($regml(1) == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
  Bitly %method $2-
}
#Bitly end
alias EchoBitly { Bitly echo -a $1- }
alias -l Bitly {
  $1-2 07Searching 04B06i07t09l03y........
  var %sockname $+(Bitly,$network,$2,$ticks)
  sockopen %sockname bit.ly 80
  sockmark %sockname $1-2 $+(/?s=&keyword=&url=,$3-)
}
On *:sockopen:Bitly*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
    sockwrite -n $sockname Host: bit.ly
    sockwrite -n $sockname $crlf
  }
  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:Bitly*: {
  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  else {
    var %Bitly | sockread %Bitly
    if ($regex(%bitly,/<input id="shortened-url" value="(.*)"/)) {
       $gettok($sock($sockname).mark,1-2,32) 04B06i07t09l03y 04» $+(07,$regml(1),)
    }
  }
}

Comments

Sign in to comment.
FordLawnmower   -  Jan 14, 2012

@GTAXL Here is is.gd

  • Same as most of my scripts you need to activate for each channel (+gd/-gd)
  • Triggers are @gd !gd. The @ trigger will message the channel. The ! Trigger will notice the user.
  • Voice or higher is needed to use @gd. Ops or higher is needed to activate/deactivate the script in a channel.
  • There is an on off switch on channel/status popup.
  • Local alias for personal use : /is.gd
  • Edit the alias is.gd.logo to change the logo.
;is.gd url shortener by Ford_Lawnmower irc.abjects.net #mIRC
alias -l is.gd.logo return $+($chr(2),$chr(3),04,$chr(44),00,IS,$chr(15)) 
menu Channel,Status {
  .$iif($group(#is.gd) == On,$style(1)) is.gd Trigger
  ..$iif($group(#is.gd) == On,$style(2)) On: .enable #is.gd
  ..$iif($group(#is.gd) == Off,$style(2)) Off: .disable #is.gd
}
#is.gd on
On $*:Text:/^(\+|-|!|@)gd*/Si:#: {
  var %action $regml(1)
  if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
    if (%action == +) {
      if ($istok(%is.gdChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the is.gd script }
      else { 
        .enable #is.gd
        Set %is.gdChanList $addtok(%is.gdChanList,$+($network,$chan),32)
        .msg $chan $nick has activated the is.gd script for $chan .
      }
    }
    else {
      if (!$istok(%is.gdChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the is.gd script }
      else { 
        Set %is.gdChanList $remtok(%is.gdChanList,$+($network,$chan),1,32)
        .msg $chan $nick has deactivated the is.gd script for $chan . 
      }
    }
  }
  elseif (!$timer($+(is.gd,$network,$nick))) && ($istok(%is.gdChanList,$+($network,$chan),32)) {
    .timer $+ $+(is.gd,$network,$nick) 1 6 noop
    var %method $iif(%action == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%|\+)/),.msg $chan,.notice $nick))
    Getis.gd %method $2-
  }
}
#is.gd end
alias is.gd { Getis.gd echo -a $1- }
alias -l Getis.gd {
  var %sockname $+(is.gd,$network,$2,$ticks)
  sockopen %sockname is.gd 80
  sockmark %sockname $1-2 $+(/create.php?url=,$urlencode($3))
}
On *:sockopen:is.gd*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
    sockwrite -n $sockname Host: $sock($sockname).addr
    sockwrite -n $sockname $crlf
  }
  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:is.gd*: {
  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  else {
    var %is.gd | sockread %is.gd
    if ($regex(comment,%is.gd,/createformlabel">(.*?)</i) && $regex(%is.gd,/id="short_url"\svalue="(.*?)"/i)) {
      $gettok($sock($sockname).mark,1-2,32) $is.gd.logo $regml(comment,1)
      $gettok($sock($sockname).mark,1-2,32) $is.gd.logo $+($chr(31),$regml(1))
    }
    elseif ($regex(comment,%is.gd,/createformlabel">(.*?)</i)) {
      $gettok($sock($sockname).mark,1-2,32) $is.gd.logo $regml(comment,1)
      $gettok($sock($sockname).mark,1-2,32) $is.gd.logo *invalid url*
    }
  }
}
alias -l urlencode { return $regsubex($1-,/([^a-z0-9])/ig,% $+ $base($asc(\t),10,16,2)) }
 Respond  
GTAXL   -  Jan 13, 2012

You should really make one for is.gd :)

 Respond  
Fawkes   -  Aug 26, 2011

@FordLawnmower
Can you modified Url shorterer bit.ly like lshort ? with customize url.

 Respond  
FordLawnmower   -  Dec 28, 2010

Something seriously wrong with the bit.ly site. I'll have a look at it as soon as it stops ping flooding. It's a non-stop image download that sucks down your cpu's. Snow flakes I suppose.

 Respond  
Conscious   -  Dec 27, 2010

z.pe doesnt work for me anymore...

"Services for this domain have been discontinued"

Odd. Anyway, rather nice script! 7/10

 Respond  
MashhitDK   -  Dec 27, 2010

Just tried out the "original" script you posted plus the onces you posted here in comments.

Doesn't seem to be working... besides shadyurl which made Me laugh :P
Awesome work haha :P not quite what I'm looking for... but BiG UPs...
sure it will come in handy... :D:D

Anyways... I'm looking for something like tinyurl that will shorten the links to something not quite as shady :P

 Respond  
Raicho Ichisada   -  Jun 22, 2010

not work in my mirc :3

 Respond  
gogy_st   -  May 04, 2010

tnx

 Respond  
Luke   -  Mar 27, 2010

Wow Thanks Ford, that was quick. :)

 Respond  
FordLawnmower   -  Mar 26, 2010

Sure Luke. Here it is:

;lshort Url Shortener by Ford_Lawnmower irc.mindforge.org #USA-Chat
menu Channel,Status {
  .$iif($group(#lshort) == On,$style(1)) lshort Trigger
  ..$iif($group(#lshort) == On,$style(2)) On: .enable #lshort
  ..$iif($group(#lshort) == Off,$style(2)) Off: .disable #lshort
}
#lshort on
On $*:Text:/^(!|@)lshort.*/Si:#: {
  if ($timer($+(lshort,$network,$nick))) { return }
  .timer $+ $+(lshort,$network,$nick) 1 6 noop
  var %method $iif($regml(1) == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
  Getlshort %method $2-
}
#lshort end
alias lshort { Getlshort echo -a $1- }
alias -l Getlshort {
  $1-2 07Searching ........
  var %sockname $+(lshort,$network,$2,$ticks)
  sockopen %sockname lshort.co.cc 80
  sockmark %sockname $1-2 $+(/index.php?url=,$3,&alias=,$4)
}
On *:sockopen:lshort*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
    sockwrite -n $sockname Host: lshort.co.cc
    sockwrite -n $sockname $crlf
  }
  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:lshort*: {
  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  else {
    var %lshort | sockread %lshort
    if ($regex(%lshort,/<p><strong>([^<]*)<\/strong><br\s\/>/)) {
      $gettok($sock($sockname).mark,1-2,32) 04l06s07h09o03r06t 04» $+(07,$regml(1),)
    }
  }
}

The alias function also works on this. Example:
!lshort google.com mazogoogle
Will return -->> http://lshort.co.cc/mazogoogle

 Respond  
Luke   -  Mar 26, 2010

Hey Ford Could you make one for http://www.lshort.co.cc please Thanks :)

 Respond  
FordLawnmower   -  Mar 24, 2010

:)

 Respond  
montague   -  Mar 24, 2010

zomg.. that was too fast.. heh thanks Fordlawnmower

 Respond  
FordLawnmower   -  Mar 24, 2010

O.o That site is a little warped ;/
Here it is though :)

;shadyurl Url Shortener by Ford_Lawnmower irc.mindforge.org #USA-Chat
menu Channel,Status {
  .$iif($group(#shadyurl) == On,$style(1)) shadyurl Trigger
  ..$iif($group(#shadyurl) == On,$style(2)) On: .enable #shadyurl
  ..$iif($group(#shadyurl) == Off,$style(2)) Off: .disable #shadyurl
}
#shadyurl on
On $*:Text:/^(!|@)shadyurl.*/Si:#: {
  if ($timer($+(shadyurl,$network,$nick))) { return }
  .timer $+ $+(shadyurl,$network,$nick) 1 6 noop
  var %method $iif($regml(1) == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
  Getshadyurl %method $2-
}
#shadyurl end
alias shadyurl { Getshadyurl echo -a $1- }
alias -l Getshadyurl {
  $1-2 07Searching ........
  var %sockname $+(shadyurl,$network,$2,$ticks)
  sockopen %sockname www.shadyurl.com 80
  sockmark %sockname $1-2 $+(/create.php?myUrl=,$3-)
}
On *:sockopen:shadyurl*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
    sockwrite -n $sockname Host: www.shadyurl.com
    sockwrite -n $sockname $crlf
  }
  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:shadyurl*: {
  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  else {
    var %shadyurl | sockread %shadyurl
    if ($regex(%shadyurl,/<p>is now<\/p> <a href='([^<]*)'>/)) {
      $gettok($sock($sockname).mark,1-2,32) 04S06H07a09d03y 04» $+(07,$regml(1),)
    }
  }
}
 Respond  
montague   -  Mar 24, 2010

works perfecly.. 10/10!
if u could make an url looks more suspicious and frightening from http://www.shadyurl.com/
it will be much more fun :D just a thought :P

 Respond  
Luke   -  Dec 02, 2009

Ok Thanks

Also you know on This bit
sockmark %sockname $1-2 $+(/?s=&keyword=&url=,$3-)

is there a way you could make it so you can do !bitly www.google.co.uk google (<< = Keyword) << but the keyword can only be used by me?

So like then it would return bit.ly/google

 Respond  
FordLawnmower   -  Dec 01, 2009

No problem Luke :)
I'll let you know when I get to the other script.

 Respond  
Luke   -  Dec 01, 2009

Wow Ford (its me Luke) Thanks For this I always wanted a bitly converter script.

Any news on the other script I requested?

Thanks :D

 Respond  
FordLawnmower   -  Nov 30, 2009

Yep, that's about as short as it gets.

 Respond  
^Neptune   -  Nov 30, 2009

For example this is google: http://z.pe/1iF
And this is hawkee: http://z.pe/Fo1

Pretty short eh?

 Respond  
FordLawnmower   -  Nov 29, 2009

Yea, that's a good point sunslayer. It's weird , but that site will produce a link for anything you send it. I tried this -->> http://bit.ly/?s=&keyword=&url=gobblediegook
And the site spit out this -->> http://bit.ly/6cx8vo
This site will produce a valid link if you send it yahoo.com, www.yahoo.com, http://www.yahoo.com or http://yahoo.com
So, unless I wanted to write a routine to check the validity of a link before I run the bitly routine, there is not much I can check for. I suppose I could check for at least one .(dot), as the list of valid extensions is no longer limited to .com,.net,.edu, etc.
.ly , I sure never heard of that one.

 Respond  
sunslayer   -  Nov 29, 2009

btw, z.pe is the shortest URL shortener ever to exist. thats what she said.

you should probably check to make sure that they are putting a url and not just some text

 Respond  
FordLawnmower   -  Nov 29, 2009

Oh, thanks for the info ^Neptune :) I've always used tinyurl.

 Respond  
^Neptune   -  Nov 29, 2009

btw, z.pe is the shortest URL shortener ever to exist.

 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.