1
0
mirror of https://gitlab.com/simple-stock-bots/simple-discord-stock-bot.git synced 2025-06-16 07:16:41 +00:00

lots of small fixes

This commit is contained in:
Anson Biggs 2021-02-11 21:27:25 -07:00
parent af8f8b7a0a
commit 5629a294df
2 changed files with 14 additions and 15 deletions

15
bot.py
View File

@ -16,6 +16,7 @@ try:
except KeyError: except KeyError:
IEX_TOKEN = "" IEX_TOKEN = ""
print("Starting without an IEX Token will not allow you to get market data!") print("Starting without an IEX Token will not allow you to get market data!")
s = Symbol(IEX_TOKEN)
client = discord.Client() client = discord.Client()
@ -24,9 +25,7 @@ intents = discord.Intents.default()
intents.members = True intents.members = True
bot = commands.Bot( bot = commands.Bot(
command_prefix="/", command_prefix="/",
description="Simple bot for getting stock market information. " description=s.help_text,
+ "The bot responds to any ticker in a message with a dollar sign: $tsla. "
+ "It also supports the commands below.",
intents=intents, intents=intents,
) )
@ -126,7 +125,10 @@ async def search(ctx, *, query: str):
async def crypto(ctx, symbol: str): async def crypto(ctx, symbol: str):
"""Get the price of a cryptocurrency using in USD.""" """Get the price of a cryptocurrency using in USD."""
reply = s.crypto_reply(symbol) 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() @bot.command()
@ -165,6 +167,7 @@ async def intra(ctx, sym: str):
filename=f"{symbol.upper()}:{datetime.date.today().strftime('%d%b%Y')}.png", filename=f"{symbol.upper()}:{datetime.date.today().strftime('%d%b%Y')}.png",
), ),
) )
await ctx.send(f"{s.price_reply([symbol])[symbol]}")
@bot.command() @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", filename=f"{symbol.upper()}:{datetime.date.today().strftime('1M%d%b%Y')}.png",
), ),
) )
await ctx.send(f"{s.price_reply([symbol])[symbol]}")
@bot.event @bot.event
async def on_message(message): async def on_message(message):
if message.author == client.user: if message.author.id == bot.user.id:
return return
if message.content[0] == "/": if message.content[0] == "/":
@ -222,5 +226,4 @@ async def on_message(message):
return return
s = Symbol(IEX_TOKEN)
bot.run(DISCORD_TOKEN) bot.run(DISCORD_TOKEN)

View File

@ -27,14 +27,14 @@ class Symbol:
) )
help_text = """ 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** **Commands**
- /donate [amount in USD] to donate. 🎗 - /donate information on how to donate. 🎗
- /dividend $[symbol] will return dividend information for the symbol. 📅 - /dividend $[symbol] will return dividend information for the symbol. 📅
- /intra $[symbol] Plot of the stocks movement since the last market open. 📈 - /intra $[symbol] Plot of the stocks movement since the last market open. 📈
- /chart $[symbol] Plot of the stocks movement for the past 1 month. 📊 - /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 All donations go directly towards paying for servers, and market data is provided by
[IEX Cloud](https://iexcloud.io/). [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. The best way to donate is through https://www.buymeacoffee.com/Anson which accepts Paypal or Credit card.
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.
If you have any questions get in touch: MisterBiggs#0465 or[anson@ansonbiggs.com](http://mailto:anson@ansonbiggs.com/) 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: def __init__(self, IEX_TOKEN: str) -> None: