westor

URL Grabber (based on embed.ly) for Dune2K v1.0

May 18th, 2020
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 0.98 KB | None | 0 0
  1. ; --------------
  2. alias -l api_key { return REGISTER_ON_EMBED_LY }
  3. ; --------------
  4.  
  5. alias -l urlencode { return $regsubex($1-,/([^a-z0-9])/ig,% $+ $base($asc(\t),10,16,2)) }
  6. alias -l isurl { noop $regex(isurl,$1-,m@^((?:(?:https?)://(?:www\.)?|www\.)((?:(?:[-\w]+\.)+)[-\w]+)(?::\d+)?(?:/(?:[-a-zA-Z;/\d#:_?=&@,()+~.%]*))?)$@ig) | return $iif($regml(isurl,0),1,0) }
  7.  
  8. ON *:TEXT:*:#: {
  9.   tokenize 32 $strip($1-)
  10.  
  11.   var %t = $numtok($1-,32)
  12.   var %i = 1
  13.  
  14.   while (%i <= %t) {
  15.     var %w = $gettok($1-,%i,32)
  16.  
  17.     if (%w) && ($isurl(%w)) { scan_url $chan %w }
  18.  
  19.     inc %i
  20.   }
  21. }
  22.  
  23. alias scan_url {
  24.   if (!$1) && (!$2) { return }
  25.   if ($me !ison $1) { return }
  26.  
  27.   var %v = URL_SEARCH_ $+ $ticks $+ $rand(1,100000000)
  28.   var %u = https://api.embed.ly/1/extract?key= $+ $api_key $+ &format=json&nojsoncallback=1&url= $+ $urldecode($2-)
  29.  
  30.   JSONOpen -ud %v %u
  31.   if ($jsonerror) { return }
  32.  
  33.   var %title = $json(%v,description).value
  34.  
  35.   if (%title) { msg $1 Title: %title }
  36. }
Add Comment
Please, Sign In to add comment