Skip to content
Permalink
Browse files
Add files via upload
  • Loading branch information
bovingtl committed Nov 12, 2019
0 parents commit 71b1454967c26bc4c243c7d0f860ef8c16f42afb
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 0 deletions.
@@ -0,0 +1,42 @@
import discord
import random
from discord.ext import commands
import requests
import asyncio
from urllib.request import urlopen
from bs4 import BeautifulSoup #<---package that allows me to web scrape

client = commands.Bot(command_prefix = '') #<---removed any prefix so only need to type in certain words to get a response from bot

@client.event
async def on_ready():
print('Chef Chad has awoken') #<---used to let the user know if the bot is running correctly


#inspiration from >>> https://www.youtube.com/watch?v=XQgXKtPSzUI&t=658s
myURL = 'https://www.thechefsforum.co.uk/about-us/' #<---url used for web scraping
@client.event
async def on_message(message):
if message.content == 'tell me about the chefs forum chad' or message.content == 'whats the forum':
myClient = urlopen(myURL) #<---opens a connection with the
page_html = myClient.read()
myClient.close
pageSoup = BeautifulSoup(page_html, "html.parser") #<---does the HTML parsing
aboutUs = pageSoup.find_all("div",{"id":"content"}) #<---spefically finds the location of desired text in HTML site
for about in aboutUs:
about = aboutUs[0]
await message.channel.send(about.text[0:1753]) #<---range function used to stop the scrape from exceeding 2000 character limit
if message.content == 'where can i find more?' or message.content == 'cool give me more':
await message.channel.send('Why here you go:''\n' 'https://www.thechefsforum.co.uk/about-us/') #<-- used or statatement so more than one phrase can be used
return #<---Response linked with a link to the website in use
'''
if message.content == 'lemme see a pic':
clientPic = pageSoup.find_all("img"),{"class":"wp-image-6237 size-medium alignright"}
for picture in clientPic:
picture = clientPic[0]
await message.channel.send(picture.img)''' #<---code that didnt work - tried to get the scraper to take the image and post into Discord Chat


client.run('NjI4MzYyNTM4ODIzNzEyNzg4.XcWzhw.RS8AWHp0y28MAvj4E_A4rdv10iY')


@@ -0,0 +1,46 @@
import discord
import random
from discord.ext import commands
import requests
import asyncio


#Everything needed in this .py file

client = commands.Bot(command_prefix = '')

@client.event
async def on_ready():
print('Chef Chad has awoken')


@client.command(aliases = ['Hi', 'Chad', 'Father?', 'Hello Chad', 'hello chad', 'hello', 'Hello']) #<---greeting command so when a user inputs one of these,
async def hi(ctx): #then the bot will respond
await ctx.channel.send('Hello my friend' + ', ' + ctx.message.author.mention) #<---responds with a message plus the users name


@client.command(questions = ['are you well', 'how are you']) #<---command that pciks a random response when certain question is asked
async def how(ctx):
responses = ['A little under the weather a monster will quench my thirst, make sure its zero though... Absolute zero.',
'Marvelous! The birds are chirping, and the kyles are punching their walls... The world is bliss.', 'yeahhh im pretty good']
response = random.choice(responses)
await ctx.send('well ' + ctx.message.author.mention + ', ' + (response) + '\n' + 'anyways... How can i help you?')

myUrl = 'https://www.thechefsforum.co.uk/category/news/' #<---the URL

@client.command(link = ['news please', 'news']) #<---command to link a News website when asking for News
async def news(ctx):
await ctx.send('Hmm, well the news seems fruitful:' '\n' 'https://www.thechefsforum.co.uk/category/news/')

@client.command(questions = ['you good', 'are you well', 'how are you', 'you okay']) #<---command that picks a random response when certain question is asked
async def you(ctx):

responses = ['A little under the weather a monster will quench my thirst, make sure its zero though... Absolute zero.',
'Marvelous! The birds are chirping, and the kyles are punching their walls... The world is bliss.', 'yeahhh im pretty good']
response = random.choice(responses) #<---Random function so that the bot responds with one of the choices typed out in the list
await ctx.send('well ' + ctx.message.author.mention + ', ' + (response) + '\n' + 'anyways... How can i help you?')



client.run('NjI4MzYyNTM4ODIzNzEyNzg4.XcWzhw.RS8AWHp0y28MAvj4E_A4rdv10iY')

@@ -0,0 +1,34 @@
import discord
import random
from discord.ext import commands
import requests
import asyncio
import random

client = commands.Bot(command_prefix = '')



@client.event
async def on_ready():
print('Chef Chad has awoken')

@client.event
async def on_message(message):
if message.content == 'chicken': #<---If statement so when the user picks 'chicken' from list, it responds
await message.channel.send('why not try a chicken madras?')
elif message.content == 'beef':
await message.channel.send('try and make a lasagne?' '\n' 'https://www.goodhousekeeping.com/uk/food/recipes/a544697/classic-lasagne-544697/') #<--- Links user to a web to cook lasagne
elif message.content == 'lamb':
await message.channel.send('lamb is a tough one, why not try this:' '\n' '')

if message.content == 'show me a list of currys please':
await message.channel.send('here is a website for currys. I recommend the chicken Madras!' '\n' 'https://www.bbcgoodfood.com/recipes/collection/curry')


#APIKEY = 91e262c6007a70f8f52fe5c61dfcdb7d




client.run('NjI4MzYyNTM4ODIzNzEyNzg4.XcWzhw.RS8AWHp0y28MAvj4E_A4rdv10iY')

0 comments on commit 71b1454

Please sign in to comment.