Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias -l rawurlencode {
- return $regsubex($1-,/\G(.)/g,$iif(\t !isalnum && \t !isin -_.,$chr(37) $+ $base($asc(\t),10,16,2),\t))
- }
- alias -l urlencode {
- return $replace($rawurlencode($1-),$+($chr(37),20),+)
- }
- alias ungoo.gl hfree GglShrt
- alias g.logo return 2G4o7o2g3l4e URL Shortener
- alias goo.gl {
- ;echo -a hi $1-
- if (!$hget(GglShrt,output)) { hadd -mu40 GglShrt output }
- if (!$1) { $hget(GglShrt,output) $g.logo error: insufficient parameters | ungoo.gl | halt }
- if ($sock(googleshort)) { $hget(GglShrt,output) $g.logo error: socket in use | ungoo.gl | halt }
- var %s $1, %r /(?:^|[][()<>{}'"\s])((?:(?:irc|s?ftp|https?:)\/\/|www\d*\.)[^\s./]+\.(?:\[\S*?]|\(\S*?\)|\{\S*?}|[^][()<>{}'"\s]|['"](?!\s|$|[()\[\]<>]))++)/giS
- if (!$regex(%s,%r)) { $hget(GglShrt,output) $g.logo error: invalid URL format | ungoo.gl | halt }
- sockopen googleshort goo.gl 80
- sockmark googleshort $1
- }
- on *:sockopen:googleshort:{
- var %s sockwrite -tn $sockname
- var %p = url= $+ $urlencode($sock($sockname).mark) $+ &security_token=null, %clen = $len(%p)
- %s POST /api/shorten HTTP/1.1
- %s Host: goo.gl
- %s User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
- %s Connection: close
- %s X-Auth-Google-Url-Shortener: true
- %s Content-Type: application/x-www-form-urlencoded;charset=utf-8
- %s Content-Length: %clen
- %s $crlf
- %s %p
- }
- on *:sockread:googleshort:{
- var %g
- sockread %g
- if ($regex(%g,/Location:\s(.+)/)) {
- ; $hget(GglShrt,output) $regml(1)
- set %shorty $hget(GglShrt,output) $regml(1)
- ; return %shorty
- ;$g.logo $+ :12 $sock($sockname).mark <->12
- sockclose $sockname
- ungoo.gl
- halt
- }
- }
- alias rabble2 {
- ;-// added by MERKiN 2/13/2012
- ; Remove those gay ass spaces
- %newslink = $1-
- %original = $1-
- %newslink = $strip(%newslink)
- %toklen = $numtok(%newslink, 32)
- %1st_bracket = $findtok(%newslink, $chr(93), 32)
- %chop_brack1 = $gettok(%newslink, %1st_Bracket - %toklen, 32)
- %2nd_bracket = $findtok(%chop_brack1, $chr(91), 32)
- %news_desc = $replace($gettok(%newslink, %1st_bracket - %2nd_Bracket, 32),$chr(93),)
- %lastbrack = $gettok(%newslink, %2nd_bracket - %toklen, 32)
- %linky = $findtok(%lastbrack, $chr(91), 32)
- %link_1 = $gettok(%lastbrack, %linky - %toklen, 32)
- %link_1 = $replace(%link_1, $chr(93),,$chr(91),)
- if ($numtok(%link_1,32) = 3) {
- %remtok = $gettok(%link_1, 2, 32)
- %first = $gettok(%link_1,1,32)
- %last = $gettok(%link_1,3,32)
- %both = %first $+ %last
- goo.gl %both
- ;--- need to find where the fucking link is ---;
- %replace = $findtok(%original, %remtok, 1, 32)
- %dicker = $reptok(%original, %first, %shorty, 32)
- %dicker = $remtok(%dicker, %remtok, 0, 32)
- %dicker = $remtok(%dicker, %last, 0, 32)
- }
- else { %dicker = %original }
- ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement