1
0
mirror of https://gitlab.com/simple-stock-bots/simple-discord-stock-bot.git synced 2025-08-01 19:11:34 +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 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 FROM python:3.11-slim
ENV MPLBACKEND=Agg
COPY --from=builder /root/.local /root/.local COPY --from=builder /root/.local /root/.local
RUN pip install --no-cache-dir black
ENV TELEGRAM=TOKEN ENV MPLBACKEND=Agg
ENV MARKETDATA=TOKEN
ENV DISCORD=NTMyMDQ1MjAwODIzMDI1NjY2.XDQftA.Px-arL5wDMB4XKcoPOS1r4gCGmA
ENV MARKETDATA=a01mVUZ4cW1sUUFOVWlEZ3NNTHFNeHYzS2diUUhTUVJZbzNxVVEwTUxVMD0
COPY . . COPY . .

59
bot.py
View File

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

View File

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