1
0
mirror of https://gitlab.com/simple-stock-bots/simple-discord-stock-bot.git synced 2025-08-02 11:31:26 +00:00

get bot working with telegram changes

This commit is contained in:
2023-04-16 15:09:45 -06:00
parent 32d83afdea
commit 31f12e0b45
3 changed files with 13 additions and 60 deletions

59
bot.py
View File

@@ -6,7 +6,6 @@ import os
import discord
import mplfinance as mpf
from discord.ext import commands
from discord.flags import Intents
from D_info import D_info
from symbol_router import Router
@@ -21,13 +20,12 @@ client = discord.Client()
bot = commands.Bot(
command_prefix="/", description=d.help_text, intents=Intents.default()
command_prefix="/",
description=d.help_text,
)
logger = logging.getLogger("discord")
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
)
logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO)
@bot.event
@@ -43,9 +41,7 @@ async def status(ctx: commands):
message = ""
try:
message = "Contact MisterBiggs#0465 if you need help.\n"
message += (
s.status(f"Bot recieved your message in: {bot.latency*1000:.4f}ms") + "\n"
)
message += s.status(f"Bot recieved your message in: {bot.latency*1000:.4f}ms") + "\n"
except Exception as ex:
logging.critical(ex)
@@ -68,46 +64,6 @@ async def donate(ctx: commands):
await ctx.send(d.donate_text)
@bot.command()
async def stat(ctx: commands, *, sym: str):
"""Get statistics on a list of stock symbols."""
symbols = s.find_symbols(sym)
if symbols:
for reply in s.stat_reply(symbols):
await ctx.send(reply)
@bot.command()
async def dividend(ctx: commands, *, sym: str):
"""Get dividend information on a stock symbol."""
symbols = s.find_symbols(sym)
if symbols:
for reply in s.dividend_reply(symbols):
await ctx.send(reply)
@bot.command()
async def news(ctx: commands, *, sym: str):
"""Get recent english news on a stock symbol."""
symbols = s.find_symbols(sym)
if symbols:
for reply in s.news_reply(symbols):
await ctx.send(reply)
@bot.command()
async def info(ctx: commands, *, sym: str):
"""Get information of a stock ticker."""
symbols = s.find_symbols(sym)
if symbols:
for reply in s.info_reply(symbols):
await ctx.send(reply[0:1900])
@bot.command()
async def search(ctx: commands, *, query: str):
"""Search for a stock symbol using either symbol of company name."""
@@ -122,9 +78,7 @@ async def search(ctx: commands, *, query: str):
@bot.command()
async def crypto(ctx: commands, _: str):
"""Get the price of a cryptocurrency using in USD."""
await ctx.send(
"Crypto now has native support. Any crypto can be called using two dollar signs: `$$eth` `$$btc` `$$doge`"
)
await ctx.send("Crypto now has native support. Any crypto can be called using two dollar signs: `$$eth` `$$btc` `$$doge`")
@bot.command()
@@ -143,7 +97,6 @@ async def intra(ctx: commands, sym: str):
await ctx.send("Invalid symbol please see `/help` for usage details.")
return
with ctx.channel.typing():
buf = io.BytesIO()
mpf.plot(
df,
@@ -186,7 +139,6 @@ async def chart(ctx: commands, sym: str):
await ctx.send("Invalid symbol please see `/help` for usage details.")
return
with ctx.channel.typing():
buf = io.BytesIO()
mpf.plot(
df,
@@ -230,7 +182,6 @@ async def trending(ctx: commands):
@bot.event
async def on_message(message):
if message.author.id == bot.user.id:
return
if message.content: