mruno

!gameinfo script

Sep 18th, 2013
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 20.19 KB | None | 0 0
  1. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. ;script !gameinfo Script
  3. ;version Jan2014
  4. ;author mruno
  5. ;email mruno@ircN.org
  6. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  7. ;
  8. ;added xboxOne and ps4 support
  9. ;
  10. on *:TEXT:*:#: {
  11.   if ($1 == !gamerank) || ($1 == !gameinfo) {
  12.     ;if (m isin $chan(#).mode) { .timerG. $+ $nick 1 5 .notice $nick Script is OFF due to channel being mdoerated (+m). | halt }
  13.     if (!$findtok(%gamerank,$nick,0,46)) {
  14.       set -u10 %gamerank $addtok(%gamerank,$nick,46)
  15.       var %a = gamerank
  16.       h %a chan $chan
  17.       h %a cid $cid
  18.       h %a nick $nick
  19.       h %a network $network
  20.       game $nick $2-
  21.     }
  22.     else .timerG. $+ $nick 1 5 .notice $nick Please wait 10 seconds and try again...
  23.   }
  24. }
  25. on *:INPUT:#:{
  26.   if ($1 == !gamerank) || ($1 == !gameinfo) {
  27.     ;if (m isin $chan(#).mode) { .notice $nick Script is OFF due to channel being mdoerated (+m). | halt }
  28.     var %a = gamerank
  29.     h %a chan $chan
  30.     h %a network $network
  31.     h %a cid $cid
  32.     h %a nick $me
  33.     game $me $2-
  34.   }
  35. }
  36. alias -l game {
  37.   ;if ($1 != $me) echo -st gamerank $1-
  38.   if (!$window(@Queue_game)) {
  39.     .qmake game
  40.     .qstart game 500
  41.   }
  42.   if (!$2) {
  43.     var %cmd = .qadd game .notice $1
  44.     %cmd !GameRanking by mruno. Usage: !gameinfo [options] [category] <search>
  45.     %cmd Options:
  46.     %cmd       List Results: -lN (where N is the number of results to list). Maximum of 5 results.
  47.     %cmd       Search by year: -yN (where N is the year). Example: "!game -l5y2004 Skyrim" - top 5 results for 'skyrim' in 2004.
  48.     %cmd       Sorting: -sN (where N is the type of sorting) Types: Best (default), Worst, A, Z, New, Old. Example: "!game -sNew xbox360" - Newest game for xbox 360.
  49.     %cmd Categories: 3DS, Dreamcast, DS, Gameboy, GBA, GBC, Gamecube, Genesis, iPhone, Mac, Mobile, Ngage, N64, PC, PS, PS2, PS3, PS4, Vita, PSP, Saturn, SegaCD, SNES, Wii, WiiU, Xbox, Xbox360, XboxOne
  50.     %cmd Example: " $+ $1 -l5y2004 Skyrim" - top 5 results for 'skyrim' in 2004.
  51.   }
  52.   else {
  53.     .timergamerank. $+ $1 1 30 .qadd game notice $h(gamerank,nick) Search timed out. Please try again.
  54.     var %a, %b, %p, %u, %o, %year = 0, %sort = 0
  55.     h gamerank sort Best
  56.     var %options, %category, %query, %year
  57.     h gamerank results 1
  58.     h gamerank result 1
  59.     if ($left($2,1) == -) {
  60.       set %a $3
  61.       set %options $right($2,-1)
  62.       if (y isin %options) set %year $remove($mid(%options,$pos(%options,y),5),y)
  63.       if (s isin %options) {
  64.         if ($remove($mid(%options,$pos(%options,s),4),s) == Bet) h gamerank sort Best
  65.         elseif ($remove($mid(%options,$pos(%options,s),6),s) == Wort) { h gamerank sort Worst | set %sort 1 }
  66.         elseif ($remove($mid(%options,$pos(%options,s),2),s) == A) { h gamerank sort A-z | set %sort 2 }
  67.         elseif ($remove($mid(%options,$pos(%options,s),2),s) == Z) { h gamerank sort Z-a | set %sort 3 }
  68.         elseif ($remove($mid(%options,$pos(%options,s),4),s) == New) { h gamerank sort Newest | set %sort 4 }
  69.         elseif ($remove($mid(%options,$pos(%options,s),4),s) == Old) { h gamerank sort Oldest | set %sort 5 }
  70.       }
  71.       if (l isin %options) {
  72.         if ($remove($mid(%options,$pos(%options,l,1),2),l) isnum) h gamerank results $ifmatch
  73.         elseif ($remove($mid(%options,$pos(%options,l,2),2),l) isnum) h gamerank results $ifmatch
  74.         if ($h(gamerank,results) > 5) h gamerank results 5
  75.         h gamerank result $h(gamerank,results)
  76.       }
  77.     }
  78.     else {
  79.       set %a $2
  80.       set %b $replace($3-,$chr(32),+,.,+)
  81.     }
  82.     if (%a == 3ds) set %p %a
  83.     elseif (%a == dreamcast) set %p %a
  84.     elseif (%a == ds) set %p %a
  85.     elseif (%a == gameboy) set %p %a
  86.     elseif (%a == gba) set %p %a
  87.     elseif (%a == gbc) set %p %a
  88.     elseif (%a == gamecube) set %p %a
  89.     elseif (%a == genesis) set %p %a
  90.     elseif (%a == iphone) set %p %a
  91.     elseif (%a == mac) set %p %a
  92.     elseif (%a == mobile) set %p %a
  93.     elseif (%a == ngage) set %p %a
  94.     elseif (%a == n64) set %p %a
  95.     elseif (%a == pc) set %p %a
  96.     elseif (%a == ps) set %p %a
  97.     elseif (%a == ps2) set %p %a
  98.     elseif (%a == ps3) set %p %a
  99.     elseif (%a == ps4) set %p %a
  100.     elseif (%a == vita) set %p %a
  101.     elseif (%a == psp) set %p %a
  102.     elseif (%a == saturn) set %p %a
  103.     elseif (%a == segacd) set %p %a
  104.     elseif (%a == snes) set %p %a
  105.     elseif (%a == wii) set %p %a
  106.     elseif (%a == xbox) set %p %a
  107.     elseif (%a == xbox360) set %p %a
  108.     elseif (%a == xone) || (%a == xbone) || (%a == xboxone) || (%a == xbox1) set %p xboxone
  109.     elseif (%a == wiiu) { set %p wii-u | set %a wii-u }
  110.     else {
  111.       if ($left($2,1) == -) set %b $replace($3-,$chr(32),+,.,+,-,+)
  112.       else set %b $replace($2-,$chr(32),+,.,+,-,+)
  113.       set %a $null
  114.     }
  115.     if (%a) hadd gamerank cat $upper(%a)
  116.     h gamerank query $replace(%b,+,_,.,_)
  117.     .qadd game notice $h(gamerank,nick) Searching for:  $+ $h(gamerank,sort) %p $replace(%b,+,$chr(32))
  118.     set %u http://www.gamerankings.com/browse.html?site= $+ %a $+ &cat=0&year= $+ %year $+ &numrev=3&sort= $+ %sort $+ &letter=&search= $+ %b
  119.     h gamerank u %u
  120.     gdownload complete %u gamerank.txt
  121.     ;echo -a ------ %u ---------------
  122.     .timergameinfo.gclean 0 60 gameinfo.gclean
  123.   }
  124. }
  125. alias -l complete {
  126.   if ($1 == 1) && ($2 == S_OK) {
  127.     var %a = @game, %b, %c, %d = 0, %e, %z = 0, %t, %e, %noresults = 0
  128.     while (%z < $h(gamerank,results)) {
  129.       inc %z
  130.       h gamerank no %z
  131.       if ($window(%a)) window -c %a
  132.       window -h %a
  133.       loadbuf %a gamerank.txt
  134.       if ($fline(@game,*No results were found for your search*,1)) inc %noresults
  135.       else dline %a 1- $+ $fline(%a,*"pod"*,1)
  136.       set %b $fline(@game,*href=*,%z)
  137.       if (!%b) || (%noresults) {
  138.         .qadd game $iif($h(gamerank,nick) == $me,notice $me,msg $h(gamerank,chan)) No results found for:  $+ $replace($h(gamerank,query),_,$chr(32))
  139.         .qadd game gameinfo.gclean
  140.         .timergamerank.* off
  141.         return
  142.       }
  143.       set %t game. $+ $h(gamerank,query) $+ %z
  144.       set %c $striphtml($line(%a,$calc(%b + 1)))
  145.       set %d $gettok(%c,0,44)
  146.       if ($remove($gettok(%c,%d,44),$chr(32),) isnum) set %e $ifmatch
  147.       else set %e n/a
  148.       h %t platform $striphtml($line(%a,$calc(%b - 1)))
  149.       h %t url www.gamerankings.com $+ $remove($gettok($line(@game,%b),2,34),index.html)
  150.       h %t name $striphtml($line(@game,%b))
  151.       h %t year %e
  152.       h %t dev $gettok(%c,1 - $calc(%d - 1),44)
  153.       h %t rating $iif($remove($gettok($striphtml($line(%a,$calc(%b + 2))),1,32),$chr(37)) isnum,$ifmatch,n/a)
  154.       h %t reviews $iif($gettok($striphtml($line(%a,$calc(%b + 2))),2,32) isnum,$ifmatch,n/a)
  155.       window -c %a
  156.       if ($h(gamerank,result) > 1) {
  157.         var %cmd, %date, %echo
  158.         set %echo  $+ $h(%t,platform) Game: $h(%t,name) $iif($h(gamerank,result) > 1,Date: %e)  (  $+ $h(%t,url) $+  )
  159.         if ($h(gamerank,nick) != $me) set %cmd .qadd game msg $h(gamerank,chan)
  160.         else set %cmd noop
  161.         %cmd %echo
  162.         echo -t $h(gamerank,chan) %echo
  163.       }
  164.     }
  165.     if ($h(gamerank,result) == 1) gdownload ginfo http:// $+ $h(%t,url) gamerank $+ %z $+ .txt
  166.     else { window -c %w | .qadd game gameinfo.gclean }
  167.   }
  168.   else {
  169.     .timergamerank.* off
  170.     .qadd game $iif($h(gamerank,nick) == $me,notice $me,msg $h(gamerank,chan)) Error downloading data. See $h(gamerank,u)
  171.   }
  172. }
  173. alias -l h {
  174.   if (!$2) { echo -a error: no 2 for hash table | return }
  175.   if (!$hget($1)) hmake $1 10
  176.   if ($isid) return $hget($1,$2)
  177.   else hadd $1 $2 $3-
  178. }
  179. alias -l ginfo {
  180.   if ($2 == Connect_Error) { .qadd game msg $iif($h(gamerank,nick) == $me,$me,$h(gamerank,chan)) Error downloading data. See  $+ $h(%b,url) | .timergamerank.* off }
  181.   elseif ($1 == 1) && ($2 == S_OK) {
  182.     var %w = @game. $+ $h(gamerank,no)
  183.     if ($window(%w)) window -c %w
  184.     window -h %w
  185.     loadbuf %w $4-
  186.  
  187.     var %a = 1, %b, %c = 0, %d, %o, %date, %cmd, %echo
  188.     while ($hget(game. $+ $hget(gamerank,query) $+ %a)) {
  189.       inc %c
  190.  
  191.       set %b $hget(game. $+ $hget(gamerank,query) $+ %a)
  192.       set %d $striphtml($line(%w,$calc($fline(%w,*Release Date:*,1) -1)))
  193.       if ($hget(gamerank,results) == 1) set %d $gettok(%d,1-48,32) $+ $iif($gettok(%d,0,32) > 48,...)
  194.       if ($hget(gamerank,results) > 1) set %d $gettok(%d,1-32,32) $+ $iif($gettok(%d,0,32) > 32,...)
  195.  
  196.       if ($h(gamerank,nick) != $me) set %cmd .qadd game msg $h(gamerank,chan)
  197.       else set %cmd noop
  198.       set %date $gettok($gettok($striphtml($line(%w,$fline(%w,*Release Date:*,1))),1,47),2,58)
  199.       set %echo  $+ $h(%b,platform) Game: $h(%b,name) (  $+ $h(%b,url) $+  )
  200.       %cmd %echo
  201.       if (%echo) .timergamerank.* off
  202.       echo $h(gamerank,chan) %echo
  203.       set %echo Release Date: %date Publisher/Developer: $h(%b,dev)
  204.       %cmd %echo
  205.       echo $h(gamerank,chan) %echo
  206.       if (%d) {
  207.         set %echo Info: %d
  208.         %cmd %echo
  209.         echo $h(gamerank,chan) %echo
  210.       }
  211.       set %o $remove($striphtml($line(%w,$calc($fline(%w,*Also on...*,1)+3))),/div)
  212.       if (%o) {
  213.         set %echo Also on: %o
  214.         %cmd %echo
  215.         echo $h(gamerank,chan) %echo
  216.       }
  217.       var %r = $h(%b,rating)
  218.       if (%r != n/a) {
  219.         set %echo Rating: $chr(91) $+ $iif(%r > 5.55,12,) $+ * $+ $iif(%r > 15.55,12,) $+ * $+ $iif(%r > 25.55,12,) $+ * $+ $iif(%r > 35.55,12,) $+ * $+ $iif(%r > 45.55,12,) $+ * $+ $iif(%r > 55.55,12,) $+ * $+ $iif(%r > 65.55,12,) $+ * $+ $iif(%r > 75.55,12,) $+ * $+ $iif(%r > 85.55,12,) $+ * $+ $iif(%r > 95.55,12,) $+ *] %r $+ $chr(37) $paren($h(%b,reviews) reviews)
  220.         %cmd %echo
  221.         echo $h(gamerank,chan) %echo
  222.       }
  223.       inc %a
  224.  
  225.       if (%a > $hget(gamerank,results)) break
  226.     }
  227.     window -c %w
  228.     .qadd game gameinfo.gclean
  229.   }
  230.   else { .qadd game msg $iif($h(gamerank,nick) == $me,$me,$h(gamerank,chan)) Error downloading data. See  $+ $h(%b,url) | .timergamerank.* off }
  231. }
  232.  
  233. alias -l gameinfo.gclean {
  234.   ;this removes the hash tables that were used AND closes @game
  235.   if (%gamerank) { .timergameinfo.gclean 0 60 gameinfo.gclean | return }
  236.   .timergameinfo.gclean off
  237.   hfree -w game.*
  238.   hfree -w gameinfo*
  239.   hfree -w gamerank*
  240.   set %r $findfile($mircdir,gamerank*.txt,0,1,.remove $1-)
  241.   set %r $findfile($mircdir,gdownload*.vbs,0,1,.remove $1-)
  242.   if ($window(@game)) window -c @game
  243.   .timer 1 1 if ($window(@Queue_game)) .qfree game
  244.   unset %gamerank
  245. }
  246.  
  247. on 1:UNLOAD:{
  248.   if ($window(@Queue_game)) .qfree game
  249.   gameinfo.gclean
  250. }
  251.  
  252. ;/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\
  253. ;/|\  Title  : Commmand Queues v1.1                              /|\
  254. ;/|\  Author : Nebuchadnezzar (Admin@monoChrome-Script.cjb.net)  /|\
  255. ;/|\  mIRC  : 6.1+                                              /|\
  256. ;/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\|/|\
  257. ; Description :
  258. ; Store commands in multiple queues with set delays.
  259. ; Introduction :
  260. ; This add-on allows you to create and fully manipulate your own
  261. ; command queues. While there are numerous possible uses for them,
  262. ; their most common use would be for flood buffers to prevent being
  263. ; disconnected from servers when sending a lot of commands at once
  264. ; (e.g. when pasting multiple lines of text at once). You can create
  265. ; as many queues as you like, so you can have different queues for
  266. ; different types of commands.
  267. ; Commands :
  268. ; /qmake <name>
  269. ; Creates a new queue.
  270. ; /qfree <name>
  271. ; Frees an existing queue.
  272. ; ;/qadd [-i <N>] <name> <item>
  273. ; Adds an item to an existing queue. If the -i switch is specified,
  274. ; the item is inserted as the Nth item.
  275. ; /qdel <N> <name>
  276. ; Deletes the Nth item from a queue.
  277. ; /qmove <N1> <N2> <name>
  278. ; Moves the N1st item in a queue to N2nd position.
  279. ; /qswitch <N1> <N2> <name>
  280. ; Switches the N1st and N2nd items in a queue.
  281. ; /qreplace <N> <name> <item>
  282. ; Replaces the Nth item in a queue with the new item.
  283. ; /qexec <N> <name>
  284. ; Executes the command for the Nth item in a queue.
  285. ; Note: The item will NOT be removed from the queue after
  286. ;      execution.
  287. ; /qstart <name> <delay>
  288. ; Starts calling of commands from a queue with a delay in
  289. ; milliseconds.
  290. ; /qstop <name>
  291. ; Stops calling of commands from a queue.
  292. alias -l qcall {
  293.   if ($line($1,0)) {
  294.     .qexec 1 $2
  295.     .qdel 1 $2
  296.   }
  297. }
  298. alias -l _qerr {
  299.   echo -ces Info * / $+ $1 $+ : $2-
  300.   halt
  301. }
  302. alias -l _qexec $($1-,2)
  303. alias -l _qok echo -ces Info * $1-
  304.  
  305. alias qmake {
  306.   var %com = qmake
  307.   if (!$1) _qerr %com insufficient parameters
  308.   elseif (-* iswm $1) _qerr %com invalid queue ' $+ $1 $+ '
  309.   var %win = @Queue_ $+ $1
  310.   if ($window(%win)) _qerr %com queue ' $+ $1 $+ ' exists
  311.   window -hn %win
  312.   if ($show) _qok Made queue ' $+ $1 $+ '
  313. }
  314. alias qfree {
  315.   var %com = qfree
  316.   if (!$1) _qerr %com insufficient parameters
  317.   var %win = @Queue_ $+ $1
  318.   if (!$window(%win)) _qerr %com no such queue ' $+ $1 $+ '
  319.   window -c %win
  320.   .timerqueue_ [ $+ [ $1 ] ] off
  321.   if ($show) _qok Freed queue ' $+ $1 $+ '
  322. }
  323. alias qadd {
  324.   var %com = qadd
  325.   if ($1 === -i) var %i = 1
  326.   else var %i = 0
  327.   if (((%i) && (!$4)) || ((!%i) && (!$2))) _qerr %com insufficient parameters
  328.   var %win = @Queue_ $+ $iif(%i,$3,$1)
  329.   if (!$window(%win)) _qerr %com no such queue ' $+ $iif(%i,$3,$1) $+ '
  330.   $iif(%i,iline,aline) %win $iif(%i,$2) $iif(%i,$4-,$2-)
  331.   if ($show) _qok Added item ' $+ $iif(%i,$4-,$2-) $+ ' to queue ' $+ $iif(%i,$3,$1) $+ ' $iif(%i,in $ord($iif($line(%win,0) < $2,$ifmatch,$2)) position)
  332. }
  333. alias -l qdel {
  334.   var %com = qdel
  335.   if (!$2) _qerr %com insufficient parameters
  336.   elseif ($1 !isnum 1-) _qerr %com invalid parameters
  337.   var %win = @Queue_ $+ $2
  338.   if (!$window(%win)) _qerr %com no such queue ' $+ $2 $+ '
  339.   elseif (!$line(%win,$1)) _qerr %com no such item ' $+ $1 $+ '
  340.   dline %win $1
  341.   if ($show) _qok Deleted item ' $+ $1 $+ ' from queue ' $+ $2 $+ '
  342. }
  343. alias -l qmove {
  344.   var %com = qmove
  345.   if (!$3) _qerr %com insufficient parameters
  346.   elseif (($1 !isnum 1-) || ($2 !isnum 1-)) _qerr %com invalid parameters
  347.   var %win = @Queue_ $+ $3
  348.   if (!$window(%win)) _qerr %com no such queue ' $+ $3 $+ '
  349.   var %n1 = $iif($line(%win,0) < $1,$ifmatch,$1)
  350.   var %n2 = $iif($line(%win,0) < $2,$ifmatch,$2)
  351.   var %line = $line(%win,%n1)
  352.   dline %win %n1
  353.   iline %win %n2 %line
  354.   if ($show) _qok Moved $ord(%n1) item to $ord(%n2) position in queue ' $+ $3 $+ '
  355. }
  356. alias -l qswitch {
  357.   var %com = qswitch
  358.   if (!$3) _qerr %com insufficient parameters
  359.   elseif (($1 !isnum 1-) || ($2 !isnum 1-)) _qerr %com invalid parameters
  360.   var %win = @Queue_ $+ $3
  361.   if (!$window(%win)) _qerr %com no such queue ' $+ $3 $+ '
  362.   var %n1 = $iif($line(%win,0) < $1,$ifmatch,$1)
  363.   var %n2 = $iif($line(%win,0) < $2,$ifmatch,$2)
  364.   var %line = $line(%win,%n1)
  365.   rline %win %n1 $line(%win,%n2)
  366.   rline %win %n2 %line
  367.   if ($show) _qok Switched $ord(%n1) item with $ord(%n2) item in queue ' $+ $3 $+ '
  368. }
  369. alias -l qexec {
  370.   var %com = qexec
  371.   if (!$2) _qerr %com insufficient parameters
  372.   elseif ($1 !isnum 1-) _qerr %com invalid parameters
  373.   var %win = @Queue_ $+ $2
  374.   if (!$window(%win)) _qerr %com no such queue ' $+ $2 $+ '
  375.   var %n = $iif($line(%win,0) < $1,$ifmatch,$1)
  376.   tokenize 124 $line(%win,%n)
  377.   _qexec $*
  378.   if ($show) _qok Executed $ord(%n) item in queue ' $+ $mid(%win,8) $+ '
  379. }
  380. alias qstart {
  381.   var %com = qstart
  382.   if (!$2) _qerr %com insufficient parameters
  383.   elseif ($2 !isnum 0-) _qerr %com invalid parameters
  384.   var %win = @Queue_ $+ $1
  385.   if (!$window(%win)) _qerr %com no such queue ' $+ $1 $+ '
  386.   .timerqueue_ [ $+ [ $1 ] ] -mo 0 $2 qcall %win $1
  387.   if ($show) _qok Started queue ' $+ $1 $+ ' with a delay of ' $+ $2 $+ ms'
  388. }
  389. alias -l qdelay {
  390.   var %com = qdelay
  391.   if (!$2) _qerr %com insufficient parameters
  392.   elseif ($2 !isnum 0-) _qerr %com invalid parameters
  393.   elseif (!$timer(queue_ [ $+ [ $1 ] ])) _qerr %com queue not started ' $+ $1 $+ '
  394.   .timerqueue_ [ $+ [ $1 ] ] -mo 0 $2 qcall %win $1
  395.   if ($show) _qok Changed delay to ' $+ $2 $+ ms' in queue ' $+ $1 $+ '
  396. }
  397. alias -l qstop {
  398.   var %com = qstop
  399.   if (!$1) _qerr %com insufficient parameters
  400.   elseif (!$timer(queue_ [ $+ [ $1 ] ])) _qerr %com queue not started ' $+ $1 $+ '
  401.   .timerqueue_ [ $+ [ $1 ] ] off
  402.   if ($show) _qok Stopped queue ' $+ $1 $+ '
  403. }
  404.  
  405. ;==================================================================================
  406. ;Author  : fubar
  407. ;Function: $striphtml identifier
  408. ;          This identifier strips html code from a string of text.
  409. ;         Good for using when retrieving webpages within mirc.  
  410. ;==================================================================================
  411. ;
  412. ;This identifier strips html code from a string of text. Good for using when retrieving webpages within mirc.
  413. ;
  414. ;Usage: $striphtml(html code)
  415. alias -l Xchr {
  416.   var %return $regsubex($regsubex($1-,/&#x([A-F0-9]{1,2});/g,$chr($base($regml(\n),16,10))),/&#([0-9]{2});/g,$chr(\1))
  417.   return $replacecs(%return,&ndash;,–,&middot;,·,&raquo;,»,&laquo;,«,&Uuml;,Ü,&uuml;,ü,&Aacute;,Á,&aacute;,á,&Eacute;,$&
  418.     É,&eacute;,é,&Iacute;,Í,&iacute;,í,&Oacute;,Ó,&oacute;,ó,&Ntilde;,Ñ,&ntilde;,ñ,&Uacute;,Ú,&uacute;,ú,&nbsp;,$chr(32),$&
  419.     &aelig;,æ,&quot;,")
  420. }
  421. alias -l striphtml {
  422.   ; making sure there are parameters to work with
  423.   IF ($1) {
  424.     ; Setting my variables. The %opt is set kind of funky
  425.     ; all it does is combine <two><brackets> into 1 <twobrackets>, fewer loops this way
  426.     ; also stripped tab spaces
  427.     VAR %strip,%opt = <> $remove($1-,> <,><,$chr(9)) <>,%n = 2
  428.     ; using $gettok() I checked the text in front of '>' (chr 62)
  429.     ; then the second $gettok checks the text behind '<' (chr 60)
  430.     ; so I'm extracting anything between >text<
  431.     WHILE ($gettok($gettok(%opt,%n,62),1,60)) {
  432.       ; take each peice of text and add it to the same variable
  433.       %strip = %strip $ifmatch
  434.       %strip = $replace(%strip,&quot;,")
  435.       ; increase the variable so the while statement can check the next part
  436.       INC %n
  437.     }
  438.     ; now that the loop has finished we can return the stripped html code
  439.     RETURN $xchr(%strip)
  440.   }
  441. }
  442.  
  443. ;/download by SReject
  444. ;http://www.hawkee.com/snippet/9318/
  445. alias gDownload {
  446.   if ($regex(Args,$1-,^-c (?|(?:"(?=.+")([^"]+)")|(\S+)) (\S+) (?|(?:"(?=.+")([^"]+)")|(\S+)) (\S+)$)) {
  447.     var %callback = $regml(Args,1)
  448.     var %url = $regml(Args,2)
  449.     var %file = $qt($regml(Args,3))
  450.     var %com = $regml(Args,4)
  451.     var %r = $iif($comerr,1,$com(%com).result)
  452.     .remove $qt($scriptdir $+ %com)
  453.     if ($com(%com)) { .comclose %com }
  454.  
  455.     if (%r == -1) { %callback 1 S_OK %url $qt(%file) }
  456.     elseif (%r == 1) { %callback 0 UnKnown_ComErr %url $qt(%file) }
  457.     elseif (%r == 2) { %callback 0 IE6+_Needed %url $qt(%file) }
  458.     elseif (%r == 3) { %callback 0 Connect_Error %url $qt(%file) }
  459.     elseif (%r == 4) { %callback 0 Newer_ActiveX_Needed %url $qt(%file) }
  460.     elseif (%r == 5) { %callback 0 Writefile_Error %url $qt(%file) }
  461.     else { %callback 0 Unknown_Error %url $qt(%file) }
  462.   }
  463.   elseif ($1 != -c) {
  464.     if ($isid) || (!$regex(Args,$1-,^(?|(?:"(?=.+")([^"]+)")|(\S+)) (\S+) (?|(?:"(?=.+")([^"]+)")|(\S+))$)) || ($regml(Args,0) != 3) { return }
  465.  
  466.     var %callback = $regml(Args,1)
  467.     var %url = $qt($regml(Args,2))
  468.     var %file = $qt($iif(: isin $regml(Args,3),$v2,$mircdir $+ $v2))
  469.     var %com = gdownload $+ $ticks $+ .vbs
  470.     var %s = $qt($scriptdir $+ %com)
  471.     var %w = write %s
  472.  
  473.     %w on error resume next
  474.     %w Set C = CreateObject("msxml2.xmlhttp.3.0")
  475.     %w if (err.number <> 0) then
  476.     %w   err.clear
  477.     %w   set C = CreateObject("msxml2.xmlhttp")
  478.     %w   if (err.number <> 0) then
  479.     %w     err.clear
  480.     %w     set C = CreateObject("XMLHttpRequest")
  481.     %w     if (err.number <> 0) then wscript.quit(2)
  482.     %w   end if
  483.     %w end if
  484.     %w C.open "GET", %url $+ , false
  485.     %w C.send
  486.     %w if (err.number <> 0) then wscript.quit(3)
  487.     %w set O = createobject("adodb.stream")
  488.     %w if (err.number <> 0) then wscript.quit(4)
  489.     %w O.type=1
  490.     %w O.mode=3
  491.     %w O.open
  492.     %w O.write C.responsebody
  493.     %w O.savetofile %file $+ ,2
  494.     %w if (err.number <> 0) then wscript.quit(5)
  495.     %w O.close
  496.     %w wscript.quit(-1)
  497.  
  498.     .comopen %com WScript.Shell
  499.     if ($comerr || !$comcall(%com,gdownload -c $qt(%callback) $noqt(%url) %file,run,1,bstr*,%s,uint,1,bool,true)) { goto error }
  500.     return
  501.   }
  502.   :error
  503.   if ($error) { reseterror }
  504.   if ($isfile(%s)) { .remove %s }
  505.   if ($com(%com)) { .comclose %com }
  506. }
Add Comment
Please, Sign In to add comment