Advertisement
illpastethat

StockQuote Script (Latest Price and Change) v1.0

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