🐛
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import json, urllib, random, datetime, string
|
import json, urllib, datetime, string
|
||||||
|
|
||||||
from . import hangmanDraw, money
|
from . import hangmanDraw, money
|
||||||
from funcs import getName, logThis
|
from funcs import getName, logThis
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import finnhub, json
|
import json
|
||||||
|
|
||||||
from funcs import getName
|
from funcs import getName
|
||||||
from .money import checkBalance, addMoney
|
from .money import checkBalance, addMoney
|
||||||
@@ -13,7 +13,7 @@ def getPrice(symbol : str,finnhubClient):
|
|||||||
def getPortfolio(user : str,finnhubClient):
|
def getPortfolio(user : str,finnhubClient):
|
||||||
with open("resources/games/investments.json") as f:
|
with open("resources/games/investments.json") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
if user not in data or data[user] == {}:
|
if user not in data or data[user] == {}:
|
||||||
return f"{getName(user)} does not have a stock portfolio."
|
return f"{getName(user)} does not have a stock portfolio."
|
||||||
else:
|
else:
|
||||||
@@ -56,9 +56,8 @@ def buyStock(user : str, stock : str, buyAmount : int,finnhubClient):
|
|||||||
|
|
||||||
with open("resources/games/investments.json", "w") as f:
|
with open("resources/games/investments.json", "w") as f:
|
||||||
json.dump(data,f,indent=4)
|
json.dump(data,f,indent=4)
|
||||||
|
|
||||||
return f"{getName(user)} bought {buyAmount} GwendoBucks worth of {stock} stock"
|
|
||||||
|
|
||||||
|
return f"{getName(user)} bought {buyAmount} GwendoBucks worth of {stock} stock"
|
||||||
else:
|
else:
|
||||||
return f"{stock} is not traded on the american market."
|
return f"{stock} is not traded on the american market."
|
||||||
else:
|
else:
|
||||||
@@ -70,9 +69,9 @@ def sellStock(user : str, stock : str, sellAmount : int,finnhubClient):
|
|||||||
if sellAmount > 0:
|
if sellAmount > 0:
|
||||||
with open("resources/games/investments.json", "r") as f:
|
with open("resources/games/investments.json", "r") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
stock = stock.upper()
|
stock = stock.upper()
|
||||||
|
|
||||||
if user in data and stock in data[user]:
|
if user in data and stock in data[user]:
|
||||||
value = data[user][stock]
|
value = data[user][stock]
|
||||||
stockPrice = getPrice(stock,finnhubClient)
|
stockPrice = getPrice(stock,finnhubClient)
|
||||||
@@ -89,7 +88,7 @@ def sellStock(user : str, stock : str, sellAmount : int,finnhubClient):
|
|||||||
|
|
||||||
with open("resources/games/investments.json", "w") as f:
|
with open("resources/games/investments.json", "w") as f:
|
||||||
json.dump(data,f,indent=4)
|
json.dump(data,f,indent=4)
|
||||||
|
|
||||||
return f"{getName(user)} sold {sellAmount} GwendoBucks worth of {stock} stock"
|
return f"{getName(user)} sold {sellAmount} GwendoBucks worth of {stock} stock"
|
||||||
else:
|
else:
|
||||||
return f"You don't have enough {stock} stocks to do that"
|
return f"You don't have enough {stock} stocks to do that"
|
||||||
@@ -120,7 +119,7 @@ def parseInvest(content: str, user : str,finnhubClient):
|
|||||||
return "The command must be given as \"!invest buy [stock] [amount of GwendoBucks to purchase with]\""
|
return "The command must be given as \"!invest buy [stock] [amount of GwendoBucks to purchase with]\""
|
||||||
else:
|
else:
|
||||||
return "You must give both a stock name and an amount of gwendobucks you wish to spend."
|
return "You must give both a stock name and an amount of gwendobucks you wish to spend."
|
||||||
|
|
||||||
elif content.startswith("sell"):
|
elif content.startswith("sell"):
|
||||||
commands = content.split(" ")
|
commands = content.split(" ")
|
||||||
if len(commands) == 3:
|
if len(commands) == 3:
|
||||||
|
|||||||
Reference in New Issue
Block a user