updating to the new api

This commit is contained in:
luke 2020-07-24 11:31:15 -07:00
parent 1d52dcd410
commit f9f9d92a94
6 changed files with 69 additions and 6 deletions

View File

@ -3,4 +3,4 @@ RUN apt-get update && apt-get install -y gcc python-pip
ADD app/requirements.txt /requirements.txt
RUN pip install -U pip && pip install -r requirements.txt
ADD app /app
CMD python /app/dragon-bot.py
CMD python /app/dragon-bot-updated.py

View File

@ -4,8 +4,8 @@ ADD app/requirements.txt /requirements.txt
RUN pip install -U pip pylint && pip install -r requirements.txt
ADD app /app
RUN printf "\n\nTesting your python code for errors\n\n" && \
pylint -E /app/*.py
#RUN printf "\n\nTesting your python code for errors\n\n" && \
# pylint -E /app/*.py
WORKDIR /app
RUN printf "\n#########################\n Run dragon bot by typing \n python dragon-bot.py\n#########################\n\n"

63
app/dragon-bot-updated.py Normal file
View File

@ -0,0 +1,63 @@
import os
import random
from discord.ext import commands
TOKEN = os.getenv('token')
bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
print(f'{bot.user.name} has connected to Discord!')
# @bot.event
# async def on_member_join(member):
# await member.create_dm()
# await member.dm_channel.send(
# f'Hi {member.name}, welcome to my ths server!'
# )
@bot.command(name='corona')
async def corona(ctx):
import corona
result = corona.parse_message(ctx.message.content)
await ctx.send(embed=result)
@bot.command(name='stock')
async def stock(ctx):
import stock
result = stock.parse_message(ctx.message.content)
await ctx.send(embed=result)
@bot.command(name='8ball')
async def eight_ball(ctx):
import eight_ball
result = eight_ball.check_8ball(ctx.message.content)
await ctx.send(result)
@bot.command(name='purge')
async def purge(ctx):
def is_me(m):
return m.author == ctx.message.author
num = 20
if len(ctx.message.content.split()) > 1:
try:
num = int(ctx.message.content.split()[1]) + 1
except ValueError:
await ctx.send(
ctx.message.channel,
"You need to give me a number, you entered {}".format(
ctx.message.content.split()[1]
)
)
return
await ctx.message.channel.purge(limit=num, check=is_me)
bot.run(TOKEN)

View File

@ -48,7 +48,7 @@ async def on_ready():
game=discord.Game(name='Type !help to see what I can do')
)
if not debug:
#if not debug:
# await client.edit_profile(avatar=set_avatar.change_bots_avatar())
print("\n********************************")

View File

@ -1,5 +1,5 @@
beautifulsoup4
discord.py==0.16.12
discord.py
gTTS
gTTS-token
lxml

View File

@ -2,7 +2,7 @@ import discord
import os
import requests
def parse_share(msg):
def parse_message(msg):
if len(msg.split()) > 1:
try:
res = ''