if (word(2 $loadinfo()) != [pf]) { load -pf $word(1 $loadinfo()); return; }; # Copyright (c) 2004 BlackJac@EFNet # # Version: 1.2.2005.03.04.1 # # This script will convert a long URL mentioned in a channel into a # TinyURL.com URL automatically. package tinyurl; # Watch these channels for long URLs to convert to TinyURL URLs (leave a # space between each channel; use "*" for all channels): assign TINYURL_CHANS #example1 #example2 #example3; # Set this to 1 to display the TinyURL results to the channel from which # the long URL came; set it to 0 to only echo the results to yourself: assign TINYURL_DISPLAY 0; # Require original URLs to be this many characters before converting to a # TinyURL URL: assign TINYURL_LEN 75; alias tinyurl.convert (nick, chan, url, void) { if (nick && chan && url && !tinyurl.nick) { @ tinyurl.nick = nick; @ tinyurl.chan = chan; ^on ^dcc_raw "% tinyurl.com E 80" #; if (:connect = connect(tinyurl.com 80)) { ^on ^dcc_raw "$connect tinyurl.com C" { ^on dcc_raw -"$0 tinyurl.com D *"; ^on dcc_raw -"$0 tinyurl.com D
http://tinyurl.com/*"; ^on dcc_raw -"$0 tinyurl.com C"; @ tinyurl.chan = tinyurl.nick = []; }; ^on ^dcc_raw "$connect tinyurl.com D *" #; ^on ^dcc_raw "$connect tinyurl.com D
http://tinyurl.com/*" { @ :tinyurl = after(2 > $before(3 < $3<)); if (TINYURL_DISPLAY) { defer msg $tinyurl.chan TinyURL \($tinyurl.nick\): $tinyurl; } else { xecho -w $winchan($tinyurl.chan) $banner TinyURL \($tinyurl.nick\): $tinyurl; }; }; @ :urlencoded = [url=$urlencode($url)]; msg =$connect POST /create.php HTTP/1.1$chr(13); msg =$connect Host: tinyurl.com$chr(13); msg =$connect User-Agent: Mozilla/4.0 \(compatible\; $J\; $uname(%s %r)\;\)$chr(13); msg =$connect Connection: close$chr(13); msg =$connect Cache-Control: no-cache$chr(13); msg =$connect Content-Type: application/x-www-form-urlencoded$chr(13); msg =$connect Content-Length: $strlen($urlencoded)$chr(13 10); msg =$connect $urlencoded$chr(13); } else { xecho -w $winchan($chan) $banner Unable to connect to TinyURL.com; }; ^on dcc_raw -"% tinyurl.com E 80"; }; }; fe (public public_other) tt { ^on #-$tt 5 '% \\\\[$$TINYURL_CHANS\\\\] *http://*' { @ :pattern = word(0 $pattern(http://% $2-)); if (@pattern > TINYURL_LEN) { tinyurl.convert $0-1 $pattern; }; }; };