Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;StockQuote Script (Latest Price and Change) v1.1
- ;Made by nick1
- ;View online and report bugs at http://www.hawkee.com/snippet/9578
- ;Last edit July 21, 2012
- alias stock {
- var %ticks $ticks
- tokenize 32 $strip($1-)
- if ($1) {
- set $+(%,stock.,%ticks,.msgtype) echo -a
- set $+(%,stock.,%ticks,.ticker) $1
- if (!$istok(%stock.shortened,$1,44)) {
- set $+(%,stock.,%ticks,.shorten) $upper($1)
- sockopen $+(stocklink.,%ticks) ou.gs 80
- }
- sockopen $+(stock.,%ticks) www.google.com 80
- }
- elseif ($1 == $null) {
- echo -act info 4Incorrect Syntax - Use10 /stock <ticker symbol>
- }
- }
- on $*:text:/^[!@](stock|stockquote|quote|price)(\s|$)/Si:#:{
- $iif($chan == #rsbot,halt,noop)
- if ($($+(%,botflood.,$nick),2)) {
- 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 }
- elseif ($($+(%,botflood.,$nick),2) >= 200) { msg $chan $+($nick,$chr(44)) Please Do Not Abuse The Bot. | inc -z $+(%,botflood.,$nick) 20 | halt }
- else { inc -z $+(%,botflood.,$nick) 25 }
- }
- else { inc -z $+(%,botflood.,$nick) 25 }
- var %ticks $ticks
- tokenize 32 $strip($1-)
- if ($2) {
- set $+(%,stock.,%ticks,.msgtype) $iif($chan,$iif($left($1,1) == @,msg $chan,notice $nick),msg $nick)
- set $+(%,stock.,%ticks,.ticker) $2
- if (!$istok(%stock.shortened,$2,44)) {
- set $+(%,stock.,%ticks,.shorten) $upper($2)
- sockopen $+(stocklink.,%ticks) ou.gs 80
- }
- sockopen $+(stock.,%ticks) www.google.com 80
- }
- elseif ($2 == $null) {
- notice $nick 4Incorrect Syntax - Use10 $1 <ticker symbol>
- }
- }
- on *:sockopen:stock.*: {
- sockwrite -nt $sockname GET $+(/ig/api?stock=,$($+(%,stock.,$remove($sockname,stock.),.ticker),2)) HTTP/1.1
- sockwrite -nt $sockname Host: www.google.com
- sockwrite -nt $sockname $crlf
- }
- on *:SOCKREAD:stock.*: {
- if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
- sockread &t
- var %pos $bfind(&t,1,symbol data=)
- var %pos2 $bfind(&t,%pos,><disclaimer_url)
- if (%pos != 0) {
- var %ticks $remove($sockname,stock.)
- set $+(%,stock.,%ticks,.xml) $bvar(&t,$+(%pos,-,$calc(%pos2 + 1))).text
- if ($stockparser(%ticks,trade_timestamp) == Dec 31, 1969) {
- $($+(%,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)))
- unset $+($,stock.,%ticks.*)
- sockclose $sockname
- }
- else {
- var %colorcode $iif($left($stockparser(%ticks,change),1) == +,03,04)
- $($+(%,stock.,%ticks,.msgtype),2) 4§Stock§7 $stockparser(%ticks,pretty_symbol) $+(,$openparens,07,$replace($stockparser(%ticks,company),&,&,','),$closeparens) $&
- 10Last:04 $stockparser(%ticks,last) $+(,$openparens,04,$stockparser(%ticks,trade_timestamp),$closeparens) $&
- $+(10Change:,%colorcode) $stockparser(%ticks,change) $+($openparens,%colorcode,$+($stockparser(%ticks,perc_change),%),$closeparens) $&
- 10Link:12 $+(http://ou.gs/stock_,$upper($($+(%,stock.,%ticks,.ticker),2)))
- unset $+($,stock.,%ticks.*)
- sockclose $sockname
- }
- }
- }
- on *:sockopen:stocklink.*: {
- var %symbol $($+(%,stock.,$remove($sockname,stocklink.),.shorten),2)
- sockwrite -nt $sockname GET $+(/index.php?url=http://www.google.com/finance?q=,%symbol,&alias=,stock_,%symbol) HTTP/1.1
- set %stock.shortened $addtok(%stock.shortened,%symbol,44)
- sockwrite -nt $sockname Host: ou.gs
- sockwrite -nt $sockname $crlf
- }
- alias -l openparens { return $+(01,$chr(40)) }
- alias -l closeparens { return $+(01,$chr(41)) }
- alias -l stockParser {
- ;Syntax $stockparser(ticks,DATA_TYPE)
- ;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}
- return $gettok($($+(%,stock.,$1,.xml),2),$calc($findtok($($+(%,stock.,$1,.xml),2),$+(/><,$2-,$chr(32),data=),34) + 1),34)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement