1
0
mirror of https://gitlab.com/simple-stock-bots/simple-discord-stock-bot.git synced 2025-06-16 15:17:29 +00:00
This commit is contained in:
Anson Biggs 2021-02-11 19:40:58 -07:00
parent e2b2a61bb2
commit 4b8edfac37

38
bot.py
View File

@ -1,12 +1,14 @@
import datetime
import io
import os import os
import discord import discord
import mplfinance as mpf
import pandas as pd
from discord.ext import commands from discord.ext import commands
from functions import Symbol from functions import Symbol
client = discord.Client()
DISCORD_TOKEN = os.environ["DISCORD"] DISCORD_TOKEN = os.environ["DISCORD"]
try: try:
@ -16,6 +18,8 @@ except KeyError:
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!")
client = discord.Client()
intents = discord.Intents.default() intents = discord.Intents.default()
intents.members = True intents.members = True
bot = commands.Bot( bot = commands.Bot(
@ -60,22 +64,18 @@ async def license(ctx):
async def donate(ctx): async def donate(ctx):
await ctx.send(s.donate_text) await ctx.send(s.donate_text)
if message.author == client.user:
return
@bot.command() @bot.command()
async def stat(ctx, sym: str): async def stat(ctx, *, sym: str):
symbols = s.find_symbols(sym) symbols = s.find_symbols(sym)
if symbols: if symbols:
for reply in s.stat_reply(symbols).items(): for reply in s.stat_reply(symbols).items():
await ctx.send(reply[1]) await ctx.send(reply[1])
for reply in s.price_reply(symbols).items():
await message.channel.send(reply[1])
@bot.command() @bot.command()
async def dividend(ctx, sym: str): async def dividend(ctx, *, sym: str):
symbols = s.find_symbols(sym) symbols = s.find_symbols(sym)
if symbols: if symbols:
@ -84,7 +84,7 @@ async def dividend(ctx, sym: str):
@bot.command() @bot.command()
async def news(ctx, sym: str): async def news(ctx, *, sym: str):
symbols = s.find_symbols(sym) symbols = s.find_symbols(sym)
if symbols: if symbols:
@ -93,7 +93,7 @@ async def news(ctx, sym: str):
@bot.command() @bot.command()
async def info(ctx, sym: str): async def info(ctx, *, sym: str):
symbols = s.find_symbols(sym) symbols = s.find_symbols(sym)
if symbols: if symbols:
@ -102,7 +102,7 @@ async def info(ctx, sym: str):
@bot.command() @bot.command()
async def search(ctx, query: str): async def search(ctx, *, query: str):
results = s.search_symbols(query) results = s.search_symbols(query)
if results: if results:
reply = "*Search Results:*\n`$ticker: Company Name`\n" reply = "*Search Results:*\n`$ticker: Company Name`\n"
@ -111,28 +111,12 @@ async def search(ctx, query: str):
await ctx.send(reply) await ctx.send(reply)
@bot.command()
async def intra(ctx, cmd: str):
await ctx.send("intra:" + cmd)
@bot.command()
async def chart(ctx, cmd: str):
await ctx.send("chart:" + cmd)
@bot.command() @bot.command()
async def crypto(ctx, symbol: str): async def crypto(ctx, symbol: str):
reply = s.crypto_reply(symbol) reply = s.crypto_reply(symbol)
await ctx.send(reply) await ctx.send(reply)
import pandas as pd
import io
import mplfinance as mpf
@bot.command() @bot.command()
async def intra(ctx, sym: str): async def intra(ctx, sym: str):