dd0.in URL Shortener

By GrimReaper on Jul 10, 2011

I have seen many URL shortening code's made for mIRC, So I decided to make one for TCL.

First you need to load the code into a .tcl file and save it with a unique name such as dd0.tcl

Within the eggdrop.conf or whatever you called it you need to add the line > source scripts/.tcl replacing for the name you chose.

Then rehash your bot..

Then log into your bot via Telnet and type in

.chanset #yourchannel +dd0url

Replacing #yourchannel with a channel you want it to work in.

Default trigger is .dd0

You can change the trigger by editing this section

#####################################################

set dd0char "."

#####################################################

You can change it to whatever you want to.

Hope people like this snippet.

#####################################################
##    dd0.in URL Shortener by Danneh/GrimReaper    ##
#####################################################
##                 Initial Setup                   ##
#####################################################

set dd0char "."

#####################################################
##                    End Setup                    ##
#####################################################

proc dd0url {nick host hand chan search} {
  if {[lsearch -exact [channel info $chan] +dd0url] != -1} {
    set dd0logo "\00312DD0 URL:\003"
    set dd0site "dd0.in"
    if {$search == ""} {
      putserv "PRIVMSG $chan :$dd0logo, Please enter a URL to shorten.."
    } else {
      set dd0srcurl "/api.php?action=shorturl&url=${search}&output=xml"
      if {[catch {set dd0srcsock [socket -async $dd0site 80]} sockerr]} {
        return 0
      } else {
        puts $dd0srcsock "GET $dd0srcurl HTTP/1.0"
        puts $dd0srcsock "Host: $dd0site"
        puts $dd0srcsock "User-Agent: Opera 9.6"
        puts $dd0srcsock ""
        flush $dd0srcsock
        while {![eof $dd0srcsock]} {
          set dd0status " [gets $dd0srcsock] "
          if {[regexp -all {<shorturl>(.*?)</shorturl>} $dd0status match dd0link]} {
            putserv "PRIVMSG $chan :$dd0logo ${dd0link}"
            close $dd0srcsock
            return 0
          }
        }
        close $dd0srcsock
        return 0
      }
    }
  }
}

bind pub - ${dd0char}dd0 dd0url
setudef flag dd0url
putlog "dd0.in URL Shortener by Danneh/GrimReaper"

Comments

Sign in to comment.
BigSteve   -  Jul 11, 2011

you need to make one like Cheirons url checker tells you about the url itself :D would be handy J/S

 Respond  
GrimReaper   -  Jul 10, 2011

Thanks bud.. I have been meaning to post another TCL snippet and finally got round to making one earlier today.. lol

So I thought I'd share it with people. :)

 Respond  
PuNkTuReD   -  Jul 10, 2011

nice to see you getting into other scripting languages mate...

 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.