plugins/disabled/stock_plugin.py
changeset 0 93b25987d3e5
child 17 069f7fd5545d
equal deleted inserted replaced
-1:000000000000 0:93b25987d3e5
       
     1 #$ neutron_plugin 01
       
     2 
       
     3 import urllib
       
     4 
       
     5 def handler_stock_stock(type, source, parameters):
       
     6 	if parameters:
       
     7 		data = urllib.urlopen('http://finance.yahoo.com/d/quotes.csv?s=' + parameters + '&f=sl1d1t1c1ohgv&e=.csv').read()
       
     8 		data = data.replace('"', '')
       
     9 		(stock_name, stock_current, stock_date, stock_time, stock_change, stock_open, stock_high, stock_low, stock_volume) = string.split(data.strip(), ',')
       
    10 		if stock_change == 'N/A':
       
    11 			reply = 'No Match For: ' + parameters
       
    12 		else:
       
    13 			reply = stock_name + ': ' + stock_current + ' (' + stock_change + ') - Volume: ' + stock_volume + ' - High: ' + stock_high + ' - Low: ' + stock_low
       
    14 	else:
       
    15 		reply = 'Please Enter Stock Symbol'
       
    16 	smsg(type, source, reply)
       
    17 
       
    18 register_command_handler(handler_stock_stock, '!stock', 0, 'Returns information on a particular stock (provided by Yahoo).', '!stock <code>', ['!stock AOL'])