URL Shortener with Custom Suffix

By Jethro on Aug 26, 2011

This is a forum request. The requester wants to be able to specify any keyword in his shortened URL. I thought I'd submit this as a snippet to share with you all nice folks. It uses a url shortening service called weba.im.> !shorten http://www.hawkee.com hawkee

Shortened URL: **http://weba.im/hawkee**- Added an shorten alias where you can initiate a self-trigger. ```mirc on *:sockopen:short*:{ tokenize 124 $sock($sockname).mark if ($sockerr) { msg $2 Connection Related Error! | return } var %- $sockname | $4 %- GET $1 HTTP/1.0 | $4 %- Connection: close $4 %- Host: $+(weba.im,$str($crlf,2)) } on $*:text:/^[!@.]shorten( |$)/iS:*: .ignore -cpu2 $nick 2 | $shorten($strip($2-3)) alias shorten { if ($me ison #) { tokenize 32 $strip($1-) | var %n = $iif(!$isid,$me,$nick) var %l = /(?<=^| )((?>\S{3,6}:\/\/|w{3}\056)\S+)/iS if (!$1) { .notice %n ERROR: Please supply a link to shorten! } elseif (!$regex($1,%l)) { .notice %n ERROR: $1 is not a valid link! } elseif (!$2) { .notice %n ERROR: Please include a custom keyword! } else { var %s short $+ $+($site,$ticks,$network) | sockopen %s weba.im 80 sockmark %s $+($+(/api.php?action=shorturl&url=,$iif(http:// isin $1,$& $+ $1,$+($v1,$1)),&keyword=,$2,&format=xml),|,#,|,%n,|,sockwrite -nt,|,$2) } } } on *:sockread:short*:{ tokenize 124 $sock($sockname).mark if ($sockerr) { msg $2 Reading Related Error! | return } | sockread &short if (*already exists* iswm $bvar(&short,1-).text) msg $iif($2,$2,$3) Shortened URL: $& $+($chr(2),$+(http://weba.im/,$5)) | return | msg $iif($2,$2,$3) Shortened URL: $& $iif($regex($v2,/(.*)<\/shorturl>/),$+($chr(2),$regml(1))) } ```


Sign in to comment.
alabama   -  Oct 16, 2011


RaZ   -  Aug 27, 2011

nice script

Jethro   -  Aug 27, 2011

I've modified the script according to KillerX's suggestion to include an alias that you can trigger on the client running the code using:

/shorten <Link> <Suffix>

to send out a shortened URL in the channel. This is an extra option and won't interfere with the default text event trigger.

Jethro   -  Aug 27, 2011

Yes, it is an easy implementation to include an alias to be called from the text event and self-trigger. If you wish, I can edit the script to meet your expectations.

KilllerX   -  Aug 26, 2011

personally I think I would prefer it as an alias and triggerable though a command. but. It is pretty sweet.

Ahmed Zaggoudi   -  Aug 26, 2011

nice one, with this we can save our URL and to short URL, I like it

Fawkes   -  Aug 26, 2011

9/10 from me Jethro.

But you"ll get 10/10 from me as well if you're using bit.ly. Kidding :p
Thanks Jethro.

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.