| View previous topic :: View next topic |
| Author |
Message |
Variant Guest
|
Posted: Tue Feb 03, 2004 12:54 pm Post subject: Quick Eggdrop interface to tinyurl... |
|
|
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: |
##
## 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... |
|
| Back to top |
|
 |
Yourname Master

Joined: 24 Sep 2001 Posts: 358 Location: Toronto
|
Posted: Wed Feb 04, 2004 1:54 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
GodOfSuicide Master

Joined: 17 Jun 2002 Posts: 463 Location: Austria
|
Posted: Wed Feb 04, 2004 2:06 pm Post subject: |
|
|
| the problem is : how long does such a tinyurl link last ? at least a few months i hope.... |
|
| Back to top |
|
 |
Variant Guest
|
Posted: Wed Feb 04, 2004 8:52 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|