|
@@ -6,6 +6,7 @@ from datetime import datetime
|
|
|
from config import Config
|
|
|
from logger import logger
|
|
|
from tinydb import Query
|
|
|
+import matplotlib.pyplot as plt
|
|
|
from db import MarketDB, PlayerDB, _hist, getDF
|
|
|
|
|
|
TOKEN = Config["Tokens"]["BoobyLegendsEcon"]["Token"]
|
|
@@ -49,8 +50,17 @@ def todayGrid(level=None,tier=None,columns=None):
|
|
|
cols = columns
|
|
|
return "```"+df[cols].to_string(index=False,col_space=6,na_rep="-")+footer+"```"
|
|
|
|
|
|
-
|
|
|
-def parse(input,author):
|
|
|
+async def postPlot(card=None,columns=['cost','cost-min','cost-max'],channel=None):
|
|
|
+ df=getDF(card).plot(x='date',y=columns)
|
|
|
+ plt.title(str(card))
|
|
|
+ plt.xlabel("Date")
|
|
|
+ plt.ylabel("Cost")
|
|
|
+ plt.savefig(f"plots/{card}.png")
|
|
|
+ with open(f"plots/{card}.png", 'rb') as f:
|
|
|
+ picture = discord.File(f)
|
|
|
+ await channel.send(file=picture)
|
|
|
+
|
|
|
+def parse(input,author,channel):
|
|
|
# parse the input string from the message so that we can see what we need to do
|
|
|
parts = input.strip().split()
|
|
|
logger.debug(input)
|
|
@@ -99,6 +109,11 @@ def parse(input,author):
|
|
|
history=history
|
|
|
)
|
|
|
logger.debug(retstr)
|
|
|
+ elif parts[1].upper() == "PLOT":
|
|
|
+ name = ' '.join(parts[2:])
|
|
|
+ logger.info("Plot for: "+name)
|
|
|
+ postPlot(card=name.strip(),channel=channel)
|
|
|
+ retstr = ""
|
|
|
elif parts[1].upper() in ["LOGLEVEL"]:
|
|
|
if parts[2].upper() == "DEBUG":
|
|
|
logger.setLevel(logging.DEBUG)
|
|
@@ -110,6 +125,8 @@ def parse(input,author):
|
|
|
My Key words are "!", "/", or "\\"
|
|
|
Show a Card's Historical cost with:```!History Eva Elfie``````
|
|
|
Show the current day's average prices with:```!Today```
|
|
|
+You can also filter this by Level or Level and tier:```!Today rare```or```!Today common S```
|
|
|
+You can get a graph plotted with the historical values for a star by:```!Plot Natasha Nice```
|
|
|
'''
|
|
|
else:
|
|
|
retstr = '{Author}, your command was not understood.'.format(Author=author)
|
|
@@ -136,7 +153,7 @@ async def on_message(message):
|
|
|
if message.author == client.user:
|
|
|
return
|
|
|
# get the output for the given message
|
|
|
- output = parse(message.content,message.author.display_name)
|
|
|
+ output = parse(message.content,message.author.display_name,message.channel)
|
|
|
if output is not None:
|
|
|
if len(output) > 2000:
|
|
|
output=output[:1997]+"..."
|