From 5629a294df944d30429b97500112714aa3b46370 Mon Sep 17 00:00:00 2001 From: Anson Biggs Date: Thu, 11 Feb 2021 21:27:25 -0700 Subject: [PATCH] lots of small fixes --- bot.py | 15 +++++++++------ functions.py | 14 +++++--------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/bot.py b/bot.py index f6cf617..7e5fff1 100644 --- a/bot.py +++ b/bot.py @@ -16,6 +16,7 @@ try: except KeyError: IEX_TOKEN = "" print("Starting without an IEX Token will not allow you to get market data!") +s = Symbol(IEX_TOKEN) client = discord.Client() @@ -24,9 +25,7 @@ intents = discord.Intents.default() intents.members = True bot = commands.Bot( command_prefix="/", - description="Simple bot for getting stock market information. " - + "The bot responds to any ticker in a message with a dollar sign: $tsla. " - + "It also supports the commands below.", + description=s.help_text, intents=intents, ) @@ -126,7 +125,10 @@ async def search(ctx, *, query: str): async def crypto(ctx, symbol: str): """Get the price of a cryptocurrency using in USD.""" reply = s.crypto_reply(symbol) - await ctx.send(reply) + if reply: + await ctx.send(reply) + else: + await ctx.send("Crypto Symbol could not be found.") @bot.command() @@ -165,6 +167,7 @@ async def intra(ctx, sym: str): filename=f"{symbol.upper()}:{datetime.date.today().strftime('%d%b%Y')}.png", ), ) + await ctx.send(f"{s.price_reply([symbol])[symbol]}") @bot.command() @@ -201,12 +204,13 @@ async def chart(ctx, sym: str): filename=f"{symbol.upper()}:{datetime.date.today().strftime('1M%d%b%Y')}.png", ), ) + await ctx.send(f"{s.price_reply([symbol])[symbol]}") @bot.event async def on_message(message): - if message.author == client.user: + if message.author.id == bot.user.id: return if message.content[0] == "/": @@ -222,5 +226,4 @@ async def on_message(message): return -s = Symbol(IEX_TOKEN) bot.run(DISCORD_TOKEN) diff --git a/functions.py b/functions.py index 4f04fd7..3032388 100644 --- a/functions.py +++ b/functions.py @@ -27,14 +27,14 @@ class Symbol: ) help_text = """ -Thanks for using this bot, consider supporting it by [buying me a beer.](https://www.buymeacoffee.com/Anson) +Thanks for using this bot, consider supporting it by buying me a beer: https://www.buymeacoffee.com/Anson) -Keep up with the latest news for the bot in itsTelegram Channel: https://t.me/simplestockbotnews +Keep up with the latest news for the bot in its Discord Server: https://discord.gg/VtEHyyTBAK -Full documentation on using and running your own stock bot can be found [here.](https://simple-stock-bots.gitlab.io/site) +Full documentation on using and running your own stock bot can be found here: https://simple-stock-bots.gitlab.io/site **Commands** - - /donate [amount in USD] to donate. 🎗️ + - /donate information on how to donate. 🎗️ - /dividend $[symbol] will return dividend information for the symbol. 📅 - /intra $[symbol] Plot of the stocks movement since the last market open. 📈 - /chart $[symbol] Plot of the stocks movement for the past 1 month. 📊 @@ -59,13 +59,9 @@ Simple Stock Bot is run entirely on donations. All donations go directly towards paying for servers, and market data is provided by [IEX Cloud](https://iexcloud.io/). -The easiest way to donate is to run the `/donate [amount in USD]` command with USdollars you would like to donate. - -Example: `/donate 2` would donate 2 USD. -An alternative way to donate is through https://www.buymeacoffee.com/Anson,which accepts Paypal or Credit card. +The best way to donate is through https://www.buymeacoffee.com/Anson which accepts Paypal or Credit card. If you have any questions get in touch: MisterBiggs#0465 or[anson@ansonbiggs.com](http://mailto:anson@ansonbiggs.com/) -_Donations can only be made in a chat directly with @simplestockbot_ """ def __init__(self, IEX_TOKEN: str) -> None: