This alias is designed to be used from inside a script. It will replace ALL the links in the argument you send it and return them with whatever method you want.
For Instance:
If you have a script that is returning some long crazy links, go to the portion of the script that messages the channel and put Shrinklinks in front of that line.
Lets say the message line is this.
msg #channelname Here is your crazy link - %crazylink
You would just change this to
ShrinkLinks msg #channelname Here is your crazy link - %crazylink
This will work with msg channel - msg nick - notice nick - or echo -anyvalidoptions
It will also work with the optional dot(.) , as in .msg
Example Input and Output:
Input:
/shrinklinks echo -a The other day I googled new york with http://google.com I didn't have much luck so I used http://yahoo.com . I ended up using http://wikipedia.com
Output:
The other day I googled new york with http://tinyurl.com/2tx I didn't have much luck so I used http://tinyurl.com/2ks . I ended up using http://tinyurl.com/4sgkr
Input:
/shrinklinks echo -a Hello world
Output:
Hello world
;shrinklinks by Ford_Lawnmower irc.geekshed.net -j #Script-Help
alias -l shrinklinks {
if ($wildtok($strip($4-),http://*.*,0,32) == $wildtok($strip($4-),http://tinyurl.com*,0,32)) {
$eval($1-,1)
return
}
var %count $wildtok($strip($4-),http://*.*,0,32), %text $strip($4-)
while %count {
if ($left($wildtok(%text,http://*.*,%count,32),18) != http://tinyurl.com) {
tiny $1-3 $wildtok(%text,http://*.*,%count,32) $4-
%count = 0
return
}
dec %count
}
}
alias -l Tiny {
var %sockname $+(Tiny,$network,$ticks,$r(1,$ticks))
sockopen %sockname tinyurl.com 80
sockmark %sockname $1-3 $+(/create.php?url=,$urlencode($4)) $4 $5-
}
On *:sockopen:Tiny*: {
if (!$sockerr) {
sockwrite -nt $sockname GET $gettok($sock($sockname).mark,4,32) HTTP/1.0
sockwrite -n $sockname Host: tinyurl.com
sockwrite -n $sockname $crlf
}
else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:Tiny*: {
if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
else {
var %Tiny | sockread %Tiny
if ($regex(%Tiny,/<blockquote><b>(.*)<\/b><br><small>/i)) {
tokenize 32 $sock($sockname).mark
shrinklinks $1-3 $replace($6-,$5,$remove($regml(1),preview.))
sockclose $sockname
return
}
}
}
alias -l urlencode return $regsubex($1-,/([^a-z0-9])/ig,% $+ $base($asc(\t),10,16,2))
this is what i have come up with
http://pastebin.com/QMNRn7FR
so far i can get it to work in the @window but i cant get it to work when it msg's the channel... =(
ah well i found out i was getting the nt error because i did not add your alias to the actual script was trying to add it under the alias tab..
but i added to the script and placed the shrinklinks infront of the msg parts but i still cant seem to get it working
here is what i have done
http://pastebin.com/1sHMhpKe
It looks fine. I just updated the code to what I'm using. Please try that and let me know : http://www.hawkee.com/snippet/7005/
@fungi This alias is designed to be placed in the script you want to use it in, so it's a local alias.
If you want to call the alias from outside the snippet, just change line 2 from :
alias -l shrinklinks {
To:
alias shrinklinks {
FordLawnMower,
I tried almost a dozen variations, loading it in remote, aliases, restarting mIRC and trying the code suggestions. Maybe I'm not using it right: I copied the code above, removed " -l" on line 2 and typed "/shrinklinks http://www.google.com" in the channel I was in. It still didn't return a tinyurl. Is this script indeed supposed to shorten urls while in chat, or was it maybe designed for other purposes and I'm just understanding/using it wrong?
@fungi You're not following the instructions.
Lets say the message line is this.
msg #channelname Here is your crazy link - %crazylink
You would just change this to
ShrinkLinks msg #channelname Here is your crazy link - %crazylink
You have to send the ShrinkLinks alias output information in the first two tokens.
This is made to use inside a script , but it is possible to use this in normal chat.
Example:
//shrinklinks msg # Check out this link http://www.google.com
Both slashes are needed for this to work //shrinklinks , not /shrinklinks.
You could also add a alias to the end of the script.
Just hit ctrl+end to get to the bottom of the script.
Press [enter] to add a new line.
And paste in this alias.
alias tinysend { shrinklinks msg # $$1- }
Then just save the script.
You will now be able to type /tinysend message containing links here.
If you still need help , come to irc.geekshed.net #Script-Help
@fungi This snippet was actually broken. It's updated and working again.
Change line 34.
to