This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Quick Eggdrop interface to tinyurl...

Old posts that have not been replied to for several years.
Locked
V
Variant

Quick Eggdrop interface to tinyurl...

Post by Variant »

For those of you not familiar with TinyURL, it's a great way to generate a nice, clean, short URL from a long gangly one. Much more friendly for copying from IRC if you're not using an IRC client with URL recognition.

I took a stab at a TCL script for Eggdrop that takes a URL parameter, queries the TinyURL server, then spits back out the converted URL.

Code: Select all

##
## tinyurl.tcl
## An Eggdrop interface to http://tinyurl.com/
##
## Ray Van Dolson (rayvd@bludgeon.org)
## v1.0
##

package require http

bind pub - !tinyurl tinyurl

proc tinyurl {nick host handle chan args} {
  if {[lindex $args 0] != ""} {
    set user_url [lindex $args 0]
    set url "http://tinyurl.com/create.php"
    set postdata [http::formatQuery url $user_url submit submit]
    set data [http::geturl $url -query $postdata]
    set data2 [http::data $data]
    http::cleanup $data
    foreach line [split $data2 \n] {
      if {[regexp -nocase {<blockquote>(http://tinyurl.com/.*)<\/blockquote>} $line all_matches myurl]} {
        putserv "PRIVMSG $chan :$myurl"
      }
    }
  }
}
I only program in TCL maybe once a year, so don't be too hard on me. Feel free to use, improve, whatever...
User avatar
Yourname
Master
Posts: 358
Joined: Mon Sep 24, 2001 8:00 pm
Location: Toronto

Post by Yourname »

Thanks a lot, variant. But, you can submit the script to slennox at egghelp dot org, for it to be listed in the famous egghelp tcl archive.

And btw, no offence, but I think almost all of the most famous IRC clients people use, each one of them has URL recognition? Correct me if I'm wrong.
Dormant egghead.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

the problem is : how long does such a tinyurl link last ? at least a few months i hope....
V
Variant

Post by Variant »

This is true--it's been around a while, but if it goes away then obviously this script will be useless :( And yes, most people use an IRC client with URL recognition, but I have several friends who are on my channel and use either BitchX or EPIC (or something along those lines) and get mighty upset when someone posts a really long link :) I don't think PuTTY itself does URL recognition unfortunately, although maybe there are variations on xterm/rxvt that do...

I'll submit it to that site--actually made a few changes to the code to handle timeouts a bit more gracefully if the tinyurl site is inaccessible.
Locked