This code can be easliy applied to a bot with no editing of the code.
Bot command: !bitly http://site.tld
Client command /bitly http://site.tld
; Created by Martyn Watton
; Copyright MartyniP, Martyni Productions and www.nartynip.co.uk
; Technoid IRC Network www.technoid-irc.net
alias bitlylogin {
; API INFO MUST BE SET BELOW!
; GET API INFO FROM http://bit.ly/a/your_api_key/
set %bitly.login YOURBITLYLOGIN
set %bitly.api YOURBITLYAPIKEY
; Set to 1 if your running it on a bot with a command such as !bitly link, As it will msg the channel it was posted in
set %bot 0
}
; Default bot command, you can remove this for client use, but it will not be triggered if %bitly.bot is 0
on *:TEXT:!bitly *:#: {
if (%bitly.bot == 1) {
/bitly $2
}
}
; Do not edit beond here!
on *:SockOpen:bitly: {
bitlylogin
sockwrite -nt bitly GET $+(/v3/shorten?login=,%bitly.login,&apiKey=,%bitly.api,&longUrl=,%bitly.url,&format=txt) HTTP/1.1
sockwrite -n bitly Host: api.bit.ly
sockwrite -n bitly $crlf
}
on *:SockRead:bitly: {
var %bitly.read
sockRead %bitly.read
if (http://* iswm %bitly.read) {
echo 9 -ta Shortened URL: %bitly.read
if (%bitly.bot == 1) {
/msg %bitly.chan Shorened URL: %bitly.read
}
unset %bitly.*
}
}
alias bitly {
sockClose bitly
%bitly.url = $1-
%bitly.chan = $chan
sockOpen bitly api.bit.ly 80
}