1
0
mirror of https://gitlab.com/simple-stock-bots/simple-discord-stock-bot.git synced 2025-08-01 02:51:23 +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

View File

@@ -2,18 +2,20 @@ FROM python:3.11-buster AS builder
COPY requirements.txt /requirements.txt
RUN pip install --user -r requirements.txt
COPY dev-reqs.txt /dev-reqs.txt
RUN pip install --user -r dev-reqs.txt
FROM python:3.11-slim
ENV MPLBACKEND=Agg
COPY --from=builder /root/.local /root/.local
RUN pip install --no-cache-dir black
ENV TELEGRAM=TOKEN
ENV MARKETDATA=TOKEN
ENV MPLBACKEND=Agg
ENV DISCORD=NTMyMDQ1MjAwODIzMDI1NjY2.XDQftA.Px-arL5wDMB4XKcoPOS1r4gCGmA
ENV MARKETDATA=a01mVUZ4cW1sUUFOVWlEZ3NNTHFNeHYzS2diUUhTUVJZbzNxVVEwTUxVMD0
COPY . .

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:

View File

@@ -1,4 +1,4 @@
nextcord==2.0.0
nextcord==2.4.2
requests==2.25.1
pandas==2.0.0
schedule==1.0.0