This is another one I found in my directory. It's a TinyURL snippet. It can be used both as a alias and for a bot.
Alias:
Commands are either> /preview www.tinyurl.com/link
/tinyurl www.link.com/.... [custom alias]
The alias is not necessary. Also, if the link you get does not contain your alias is because it's already taken.
The syntax is same for the bot but you need to ofcourse replace the / with a !. The bot works both in pm and in a #channel.> !tinyurl http://www.mirc.com/register.html mmmmmmmmmmirc
The link [http://www.mirc.com/register.html] was shortened to >>>http://tinyurl.com/mmmmmmmmmmirc<<<> !preview http://tinyurl.com/mmmmmmmmmmirc
The link [http://tinyurl.com/mmmmmmmmmmirc] directs to >>>http://www.mirc.com/register.html<<<
You're appreciated to come with suggestions :-)
```mirc
on $*:text:/^!(preview|tinyurl) /iS:#,?:{
$regml(1) $2-
}
alias preview {
if $1 {
if $sock(tinypreview) || $sock($+(tinypreview,$nick)) {
sockclose $v1
}
sockopen $iif($event == text,$+(tinypreview,$nick),tinypreview) tinyurl.com 80
sockmark $iif($event == text,$+(tinypreview,$nick msg $iif(#,#,$nick)),tinypreview echo -a) $1
}
else {
echo -a 4Error! No query specified!
}
}
alias tinyurl {
if $1 {
if $sock(tinyurl) || $sock($+(tinyurl,$nick)) {
sockclose $v1
}
sockopen $iif($event == text,$+(tinyurl,$nick),tinyurl) tinyurl.com 80
sockmark $iif($event == text,$+(tinyurl,$nick) msg $iif(#,#,$nick),tinyurl echo -a) $1-
}
else {
echo -a 4Error! No query specified!
}
}
on *:sockopen:tinypreview*:{
tokenize 32 $sock($sockname).mark
sockwrite -n $sockname GET $remove($3,http://,www.,tinyurl.com)) HTTP/1.1
sockwrite -n $sockname Host: tinyurl.com
sockwrite -n $sockname $crlf
}
on *:sockopen:tinyurl*:{
tokenize 32 $sock($sockname).mark
var %data $+(url=,$3,&alias=,$4,&submit=Make+TinyURL)
sockwrite -n $sockname POST /create.php HTTP/1.1
sockwrite -n $sockname Host: tinyurl.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
sockwrite -n $sockname Content-Length: $len(%data)
sockwrite -n $sockname $crlf %data
}
on *:sockread:tiny*:{
var %tinyreader
sockread %tinyreader
if $regex(%tinyreader,/Location: (.*)/) {
tokenize 32 $sock($sockname).mark
$1-2 3The link 4[12 $+ $3 $+ 4] 3directs to 4>>>12 $+ $regml(1) $+ 4<<<
sockclose $sockname
}
if $regex(%tinyreader,/blockquote>
(.*?)<\/b>/) {
tokenize 32 $sock($sockname).mark
$1-2 3The link 4[12 $+ $3 $+ 4] 3was shortened to 4>>>12 $+ $regml(1) $+ 4<<<
sockclose $sockname
}
}
```