Basically what it does is searches anything you type, If it see's a link either beginning with http:// or www. and uses a URL shortener to replace the link and shrink it.
- Code: Select all
menu * {
URL Replacer
.$iif(%shrturl == On,$style(1)) URL Replacer
..$iif(%shrturl == On,$style(2)) On: set %shrturl on
..$iif(!%shrturl,$style(2)) Off: unset %shrturl
-
}
on 1:input:*: {
if (%shrturl == on) {
if ($left($1,1) == /) { return }
elseif (l0p.us iswm $1-) { return }
else {
haltdef
var %a = $numtok($$1-,32)
while (%a) {
if (http:// isin $gettok($1-,%a,32)) || (www. isin $gettok($1-,%a,32)) {
if ($sock(l0pus)) { .sockclose l0pus }
else { sockopen l0pus www.l0p.us 80 }
set %shrt.urlget $gettok($1-,%a,32)
set %shrt.act $active
set %shrt.msg $1-
halt
dec %a
}
else { dec %a }
}
msg $active $1-
}
}
}
on *:SockOpen:l0pus: {
if ($sockerr) { echo -at Error connecting to l0p.us }
else {
sockwrite -nt l0pus GET $+(/api-make.php?alias=&url=,%shrt.urlget) HTTP/1.1
sockwrite -n l0pus Host: www.l0p.us
sockwrite -n l0pus $crlf
}
}
on *:SockRead:l0pus: {
var %read | sockRead %read
if (http://* iswm %read) {
var %urlshort = %read
msg %shrt.act $replace(%shrt.msg,%shrt.urlget,%urlshort)
unset %shrt.*
}
}
I will advise that any other on *:INPUT script's that you have loaded and working that you either turn them off or remove them as this will cause a double post.
I had a little help with it from a mate of mine called PuNkTuReD on another network. I have also tested it and it does work.