egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Quick Eggdrop interface to tinyurl...

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
Variant
Guest





PostPosted: Tue Feb 03, 2004 12:54 pm    Post subject: Quick Eggdrop interface to tinyurl... Reply with quote

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

PostPosted: Wed Feb 04, 2004 1:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
GodOfSuicide
Master


Joined: 17 Jun 2002
Posts: 463
Location: Austria

PostPosted: Wed Feb 04, 2004 2:06 pm    Post subject: Reply with quote

the problem is : how long does such a tinyurl link last ? at least a few months i hope....
Back to top
View user's profile Send private message
Variant
Guest





PostPosted: Wed Feb 04, 2004 8:52 pm    Post subject: Reply with quote

This is true--it's been around a while, but if it goes away then obviously this script will be useless Sad 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 Smile 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
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber