Bitly URL Shortener

Moderator: GeekShed.Net Staff

Bitly URL Shortener

Postby Ford » Sun Nov 29, 2009 11:25 pm

Script was requested by Luke.
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 <Ford_Lawnmower> @bitly http://pastebin.com/m63db9ac2
17:09:54 <+RingKing Searching Bitly .......
17:09:54 <+RingKing Bitly » http://bit.ly/7S3RJ7

Code: Select all
;Bitly Url Shortener by Ford_Lawnmower irc.GeekShed.net #Script-Help
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),)
    }
  }
}
Ford
 
Posts: 48
Joined: Wed Oct 28, 2009 1:01 am

Return to Script help

Who is online

Users browsing this forum: No registered users and 4 guests

cron