Advertisement
illpastethat

StockQuote Script (Latest Price and Change) v1.1

Jul 21st, 2012
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 4.07 KB | None | 0 0
  1. ;StockQuote Script (Latest Price and Change) v1.1
  2. ;Made by nick1
  3. ;View online and report bugs at http://www.hawkee.com/snippet/9578
  4. ;Last edit July 21, 2012
  5.  
  6. alias stock {
  7.   var %ticks $ticks
  8.   tokenize 32 $strip($1-)
  9.   if ($1) {
  10.     set $+(%,stock.,%ticks,.msgtype) echo -a
  11.     set $+(%,stock.,%ticks,.ticker) $1
  12.     if (!$istok(%stock.shortened,$1,44)) {
  13.       set $+(%,stock.,%ticks,.shorten) $upper($1)
  14.       sockopen $+(stocklink.,%ticks) ou.gs 80
  15.     }
  16.     sockopen $+(stock.,%ticks) www.google.com 80
  17.   }
  18.   elseif ($1 == $null) {
  19.     echo -act info 4Incorrect Syntax - Use10 /stock <ticker symbol>
  20.   }
  21. }
  22.  
  23. on $*:text:/^[!@](stock|stockquote|quote|price)(\s|$)/Si:#:{
  24.   $iif($chan == #rsbot,halt,noop)
  25.   if ($($+(%,botflood.,$nick),2)) {
  26.     if ($($+(%,botflood.,$nick),2) >= 300) { ignore -u60 $address($nick,0) | msg $chan $+($nick,$chr(44)) You Have Been Put On Ignore For 60secs For Abusing The Bot. | halt }
  27.     elseif ($($+(%,botflood.,$nick),2) >= 200) { msg $chan $+($nick,$chr(44)) Please Do Not Abuse The Bot. | inc -z $+(%,botflood.,$nick) 20 | halt }
  28.     else { inc -z $+(%,botflood.,$nick) 25 }
  29.   }
  30.   else { inc -z $+(%,botflood.,$nick) 25 }
  31.   var %ticks $ticks
  32.   tokenize 32 $strip($1-)
  33.   if ($2) {
  34.     set $+(%,stock.,%ticks,.msgtype) $iif($chan,$iif($left($1,1) == @,msg $chan,notice $nick),msg $nick)
  35.     set $+(%,stock.,%ticks,.ticker) $2
  36.     if (!$istok(%stock.shortened,$2,44)) {
  37.       set $+(%,stock.,%ticks,.shorten) $upper($2)
  38.       sockopen $+(stocklink.,%ticks) ou.gs 80
  39.     }
  40.     sockopen $+(stock.,%ticks) www.google.com 80
  41.   }
  42.   elseif ($2 == $null) {
  43.     notice $nick 4Incorrect Syntax - Use10 $1 <ticker symbol>
  44.   }
  45. }
  46.  
  47. on *:sockopen:stock.*: {  
  48.   sockwrite -nt $sockname GET $+(/ig/api?stock=,$($+(%,stock.,$remove($sockname,stock.),.ticker),2)) HTTP/1.1
  49.   sockwrite -nt $sockname Host: www.google.com
  50.   sockwrite -nt $sockname $crlf
  51. }
  52.  
  53. on *:SOCKREAD:stock.*: {
  54.   if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
  55.   sockread &t
  56.   var %pos $bfind(&t,1,symbol data=)
  57.   var %pos2 $bfind(&t,%pos,><disclaimer_url)
  58.   if (%pos != 0) {
  59.     var %ticks $remove($sockname,stock.)
  60.     set $+(%,stock.,%ticks,.xml) $bvar(&t,$+(%pos,-,$calc(%pos2 + 1))).text
  61.     if ($stockparser(%ticks,trade_timestamp) == Dec 31, 1969) {
  62.       $($+(%,stock.,%ticks,.msgtype),2) 4§Stock§7 $stockparser(%ticks,pretty_symbol) 04This symbol could not be found.  Please try again or search12 $+(http://ou.gs/stock_,$upper($($+(%,stock.,%ticks,.ticker),2)))
  63.       unset $+($,stock.,%ticks.*)
  64.       sockclose $sockname
  65.     }  
  66.     else {
  67.       var %colorcode $iif($left($stockparser(%ticks,change),1) == +,03,04)
  68.       $($+(%,stock.,%ticks,.msgtype),2) 4§Stock§7 $stockparser(%ticks,pretty_symbol) $+(,$openparens,07,$replace($stockparser(%ticks,company),&amp;,&,&#39;,'),$closeparens) $&
  69.         10Last:04 $stockparser(%ticks,last) $+(,$openparens,04,$stockparser(%ticks,trade_timestamp),$closeparens) $&
  70.         $+(10Change:,%colorcode) $stockparser(%ticks,change) $+($openparens,%colorcode,$+($stockparser(%ticks,perc_change),%),$closeparens) $&
  71.         10Link:12 $+(http://ou.gs/stock_,$upper($($+(%,stock.,%ticks,.ticker),2)))
  72.       unset $+($,stock.,%ticks.*)
  73.       sockclose $sockname
  74.     }
  75.   }
  76. }
  77.  
  78. on *:sockopen:stocklink.*: {
  79.   var %symbol $($+(%,stock.,$remove($sockname,stocklink.),.shorten),2)
  80.   sockwrite -nt $sockname GET $+(/index.php?url=http://www.google.com/finance?q=,%symbol,&alias=,stock_,%symbol) HTTP/1.1
  81.   set %stock.shortened $addtok(%stock.shortened,%symbol,44)
  82.   sockwrite -nt $sockname Host: ou.gs
  83.   sockwrite -nt $sockname $crlf
  84. }
  85.  
  86. alias -l openparens { return $+(01,$chr(40)) }
  87.  
  88. alias -l closeparens { return $+(01,$chr(41)) }
  89.  
  90. alias -l stockParser {
  91.   ;Syntax $stockparser(ticks,DATA_TYPE)
  92.   ;Options for DATA_TYPE are {pretty_symbol,company,exchange,last,high,low,volume,avg_volume,market_cap,open,y_close,change,perc_change,trade_timestamp,symbol_url,chart_url}
  93.   return $gettok($($+(%,stock.,$1,.xml),2),$calc($findtok($($+(%,stock.,$1,.xml),2),$+(/><,$2-,$chr(32),data=),34) + 1),34)
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement