Advertisement
illpastethat

URLShorten Script (Shorten Long Links) v1.0

Aug 13th, 2011
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 3.12 KB | None | 0 0
  1. ;URLShorten Script (Shorten Long Links) v1.0
  2. ;Made by nick1
  3. ;Last edit August 13 2011
  4. ;Directions: !shorten LINK (notice) @shorten LINK (Message) /shorten LINK private to yourself
  5.  
  6. alias checkifsockopen {
  7. if ($sock(%checksockname)) { sockclose %checksockname
  8.   if (%_bq.msgtype) %_bq.msgtype $+(12[4,URL,12])10 Error Encountered! |unset %_bq.*
  9.   }
  10. }
  11.  
  12. alias nohtml { return $regsubex($$1-,/^[^<]*>|<[^>]*>|<[^>]*$/g,) }
  13.  
  14. alias urlencode return $replace($regsubex($$1-,/([^\w\s])/Sg,$+(%,$base($asc(\t),10,16,2))),$chr(32),+)
  15.  
  16. on $*:text:/^[!@](tiny|shorten|bq)/Si:#: {
  17.   if ($($+(%,botflood.,$nick),2)) {
  18.     if ($($+(%,botflood.,$nick),2) >= 50) { ignore -u60 $address($nick,0) | msg $chan $+($nick,$chr(44)) You Have Been Put On Ignore For 60secs For Abusing The Bot. | halt }
  19.     elseif ($($+(%,botflood.,$nick),2) >= 40) { msg $chan $+($nick,$chr(44)) Please Do Not Abuse The Bot. | inc -z $+(%,botflood.,$nick) 20 | halt }
  20.     else { inc -z $+(%,botflood.,$nick) 25 }
  21.   }
  22.   else { inc -z $+(%,botflood.,$nick) 25 }
  23.   if ($sock(bq)) { msg $chan $nick $+ : Please wait, already working on a URL. | halt }
  24. elseif (nick1 ison $chan) { halt }
  25.   set %_bq.nick $nick
  26.   inc %shortens
  27.   set %_bq.msgtype $iif($left($1,1) == @, msg $chan, notice $nick)
  28.   set %_bq.url $2-
  29.   sockopen bq ou.gs 80
  30. }
  31.  
  32. alias shorten {
  33.   if ($isid) {
  34.     if (%_bq.shortlink) {
  35.       var %i %_bq.shortlink
  36.       unset %_bq.*
  37.       return %_bq.shortlink
  38.     }
  39.     else {
  40.       set %_bq.isid true
  41.       set %_bq.msgtype echo -ac info
  42.       set %_bq.url $1-
  43.       sockopen bq ou.gs 80
  44.     }
  45.   }
  46.   elseif ($2) {
  47.     set %_bq.nick $1
  48.     inc %shortens
  49.     set %_bq.msgtype $iif((!%_bq.msgtype),msg $active,%_bq.msgtype)
  50.     set %_bq.url $2-
  51.     sockopen bq ou.gs 80
  52.   }
  53.   elseif ($2 == $null) {
  54.     set %_bq.msgtype echo -ac info
  55.     set %_bq.url $1-
  56.     sockopen bq ou.gs 80
  57.   }
  58. }
  59.  
  60. on *:sockopen:bq: {
  61.   .timerSet 1 4 set %checksockname $sockname
  62.   .timerCheck 1 5 checkifsockopen
  63.   if (%_bq.lmgtfy) { sockwrite -nt $sockname GET /index.php?url= $+ %_bq.url $+ &alias= $+ %_bq.nick $+ -G0- $+ %shortens HTTP/1.1 }
  64.   else { sockwrite -nt $sockname GET /index.php?url= $+ $urlencode(%_bq.url) HTTP/1.1 }
  65.   sockwrite -nt $sockname Host: ou.gs
  66.   sockwrite -nt $sockname $crlf
  67. }
  68.  
  69. on *:SOCKREAD:bq: {
  70.   if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
  71.   else {
  72.     var %sockreader
  73.     sockread %sockreader
  74.     if (*<p>Short URL: <strong><a href="* iswm %sockreader) {
  75.       if (%_bq.lmgtfy) {
  76.         %_bq.msgtype %_bq.nick $+ : 12[4Helpful Link12] http://ou.gs/ $+ %_bq.nick $+ -G0- $+ %shortens
  77.         unset %_bq.*
  78.         sockclose $sockname
  79.         halt
  80.       }
  81.       if (%_bq.isid) {
  82.         tokenize 34 %sockreader
  83.         set %_bq.shortlink $2
  84.         shorten
  85.         sockclose $sockname
  86.         halt
  87.       }
  88.       else {
  89.         %_bq.msgtype 10 $+ Long URL: $iif($left(%_bq.url,7) == http://,%_bq.url,http:// $+ %_bq.url) ( $+ $len($iif($left(%_bq.url,7) == http://,%_bq.url,http:// $+ %_bq.url)) Characters) Is4 $nohtml(%sockreader)
  90.       }
  91.       unset %_bq.*
  92.       sockclose $sockname
  93.     }
  94.   }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement