Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import requests
import json
import asyncio
import os
################################################################################################################################
#Throught my code (Francesca Passmore) I refeerenced https://medium.com/disbots/how-to-make-a-discord-bot-with-python-e066b03bfd9#:~:text=How%20to%20make%20a%20simple%20discord%20bot%20with,test%20out%20everything%20...%203%20Coding%20your%20bot to help me
token= "NzgxMTYwNjQ3NTIxOTkyNzY0.X75miw.yRjYcIPHVJFxGv7_M8RoNHYx_e4"
import discord
from discord.ext import commands
bot=commands.Bot(command_prefix="")
@bot.event
async def on_ready():
print("The bot is ready")
@bot.command()
async def hello(ctx):
await ctx.send("Hi I'm Remy bot! Just say Hey and all of your wishes after as I'm now your culinary fairy god mother :)")
@bot.command()
async def Recipe(ctx,*,args):
###########################################################################################
#This is Kieran Wigley's work
file = open("suggestions.txt","a")
file.write("\n")
file.write(args)
file.close()
await ctx.send("Thank you for your suggestion, a moderator will review your suggestion and contact you shortly")
#This is the end of Kieran Wigley's work
##############################################################################################
@bot.command()
async def Id(ctx, arg):
await ctx.send("Ahhh I know the cook book is here somewhere for that recipe...")
await ctx.send("Bingo! Found it")
url= "https://api.spoonacular.com/recipes/informationBulk?apiKey=cbd2e8ce18e04227b99205001c304bfa&ids=" + str(arg)
url2="https://api.spoonacular.com/recipes/" + str(arg) + "/analyzedInstructions?apiKey=cbd2e8ce18e04227b99205001c304bfa"
response= requests.get(url)
r=response.json()
for n in r:
await ctx.send(n['title'])
await ctx.send(n['image'])
await ctx.send("These are the ingredients")
response2= requests.get(url2)
r2=response2.json()
for m in r[0]['extendedIngredients']:
await ctx.send(m['originalString'])
for n in r2[0]['steps']:
await ctx.send("This is step number " + str(n['number']))
await ctx.send(n['step'])
###############################################################################################################
#This is the start of Viktor Ivanov's code
@bot.command( name = 'Timer',
description = "Command that let's you do a simple countdown" ,
brief = 'Simple countdown function',
aliases = ['tmr', 'settime'])
async def Timer(ctx, time: int):
await ctx.channel.send("Timer started")
def check(message): #We define a function inside a function which will be in charge of stopping the timer
return message.channel == ctx.channel and message.author == ctx.author and message.content.lower() == "cancel"
try:
m = await bot.wait_for("message", check=check, timeout=time)
await ctx.send("Timer stopped")
except asyncio.TimeoutError:
await ctx.send(f"countdown finished")
#This is the end of Viktor Ivanov's code
#############################################################################################################
@bot.command()
async def Ingredients(ctx, *args):
ingredients=[]
for item in range(0, len(args)):
ingredients.append(args[item])
url="https://api.spoonacular.com/recipes/findByIngredients?apiKey=cbd2e8ce18e04227b99205001c304bfa&number=1&ranking=1&ingredients="
if len(ingredients) == 1:
await ctx.send("Just " + str(ingredients[0]) + "? No problem at all, we have plenty of that")
url=url + str(ingredients[0])
if len(ingredients) > 1:
await ctx.send("Someone got shopper-happy at the super market ;)")
url=url + str(ingredients[0])
for item in range(1,len(ingredients)):
url=url + ",+" + str(ingredients[item])
r= requests.get(url)
response=r.json()
recipeid=[]
for n in response:
await ctx.send(n['title'])
recipeid.append(n['id'])
await ctx.send("You are missing " + str(n['missedIngredientCount']) + " ingredient/s")
await ctx.send("You can use " + str(n['usedIngredientCount']) + " of your ingredients")
await ctx.send("The id is " + str(recipeid[0]))
url2="https://api.spoonacular.com/recipes/informationBulk?apiKey=cbd2e8ce18e04227b99205001c304bfa&ids=" + str(recipeid[0])
r2=requests.get(url2)
response2= r2.json()
url3="https://api.spoonacular.com/recipes/" + str(recipeid[0]) + "/analyzedInstructions?apiKey=cbd2e8ce18e04227b99205001c304bfa"
r3=requests.get(url3)
response3= r3.json()
await ctx.send("These are the ingredients:")
for m in response2[0]['extendedIngredients']:
await ctx.send(m['originalString'])
for n in response3[0]['steps']:
await ctx.send("This is step number " + str(n['number']))
await ctx.send(n['step'])
#########################################################################################################################
#This is the start of Viktor Ivanov's code
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="the 'Anyone can Cook' podcast"))
#This is the end of Viktor Ivanov's code
#########################################################################################################
@bot.command( name = 'Hey',
description = "Main talking trigger, enter anything after Hey and Remy will respond" ,
brief = 'Main talking trigger, enter anything after Hey and Remy will respond',
aliases = ['hi', 'please','can you'])
async def Hey(ctx, *args):
for item in range(0, len(args)):
if args[item] == 'thanks' or args[item] == 'thankyou':
await ctx.send("No problem chef! Have a good meal")
if args[item] == 'fuck' or args[item] == 'fucking' or args[item] == "shit" or args[item] == "smelly" or args[item] == "poo" or args[item] == "crap" or args[item] == "cunt" or args[item] == "dickhead":
import random
with open('reaction.txt') as allReactions:
lines = [line.rstrip('\n') for line in allReactions]
randomReaction = random.choice(lines)
reaction=format(randomReaction)
await ctx.send(reaction)
if args[item] == 'timer':
await ctx.send("If you'd like to set a timer, type 'Timer' and then set the amount of seconds you like")
#####################################################################################################################################
#This is the start of Viktor Ivanov's code
if args[item] == 'croissant':
await ctx.send(file=discord.File('Images/croissant.jpg'))
await ctx.send("Course: breakfast"+"\n" "Cuisine: Italian" + "\n" + "Preparation time: 1 hour" + "\n" + "Cooking time: 30 minutes")
if args[item] == 'pizza':
await ctx.send(file=discord.File('Images/pizza.webp'))
await ctx.send("Course: Lunch. Dinner. Sandwich"+"\n" "Cuisine: Italian" + "\n" + "Preparation time: 30 minutes" + "\n" + "Cooking time: 45 minutes in the oven")
if args[item] == 'burger':
await ctx.send(file=discord.File('Images/burger.jpg'))
await ctx.send("Course: Lunch. Dinner. Sandwich"+"\n" "Cuisine: American." + "\n" + "Preparation time: 30 minutes if you grind your own, 5 minutes if you buy ground chuck" + "\n" + "Cooking time: 4 to 6 minutes")
if args[item] == 'tip' or args[item] == 'kicthen' or args[item] == "safety" or args[item] == "tips":
import random
possible_responses = ["Use rubbing alcohol to clean stainless steel.",
"Prevent bubbling over with a wooden spoon.",
"Use cooking spray to make less of a mess.",
"Do not try to clean or repair an appliance when it is still plugged in.",
"Make sure you have a working smoke detector in case something does go wrong.",
"Defrost your fridge and freezer at least once a year to ensure these appliances continue to work properly.",
"Always wash your hands.",
"Always stir and lift away from you.",
"Don't set a hot glass dish on a wet or cold surface.",
"Store knives in a wooden block or in a drawer.",
"Never cook in loose clothes and keep long hair tied back.",
"Never cook while wearing dangling jewelry."]
await ctx.send(random.choice(possible_responses))
#This is the end of Viktor Ivanov's code
####################################################################################################################################
if args[item] == 'suggest' or args[item] == 'suggestion':
await ctx.send("If you'd like to suggest a recipe, please say 'Recipe', then the name of the recipe and then your email. Our moderators will then be in touch")
if args[item] == 'daily':
####################################################################################################
#This is the start of Kieran Wigley's work
import datetime
current_date = datetime.datetime.today()
await ctx.send("Its weekday " + str(current_date.isoweekday()) + "!")
if current_date.isoweekday() == 1:
await ctx.send("Mac and Cheese Monday")
url = "https://api.spoonacular.com/recipes/270723/analyzedInstructions?apiKey=2c7d213247c34ccea25c72f9fe9053e9"
url2 = "https://api.spoonacular.com/recipes/informationBulk?ids=270723&apiKey=cbd2e8ce18e04227b99205001c304bfa"
response= requests.get(url2)
rsp= response.json()
for n in rsp:
await ctx.send(n['title'])
await ctx.send(n['image'])
await ctx.send("The Ingredients are:")
for item in rsp [0]["extendedIngredients"]:
await ctx.send(item["originalString"])
for x in rsp[0]["analyzedInstructions"][0]["steps"]:
await ctx.send("This is step number " + str(x["number"]))
await ctx.send(x["step"])
########################################################
elif current_date.isoweekday() == 2:
await ctx.send("Taco Tuesday")
url = "https://api.spoonacular.com/recipes/201297/analyzedInstructions?apiKey=2c7d213247c34ccea25c72f9fe9053e9"
url2 = "https://api.spoonacular.com/recipes/informationBulk?ids=201297&apiKey=cbd2e8ce18e04227b99205001c304bfa"
response= requests.get(url2)
rsp= response.json()
for n in rsp:
await ctx.send(n['title'])
await ctx.send(n['image'])
await ctx.send("The Ingredients are:")
for item in rsp [0]["extendedIngredients"]:
await ctx.send(item["originalString"])
for x in rsp[0]["analyzedInstructions"][0]["steps"]:
await ctx.send("This is step number " + str(x["number"]))
await ctx.send(x["step"])
#######################################################
elif current_date.isoweekday() == 3:
await ctx.send("Wrap Wednesday")
url = "https://api.spoonacular.com/recipes/266692/analyzedInstructions?apiKey=2c7d213247c34ccea25c72f9fe9053e9"
url2 = "https://api.spoonacular.com/recipes/informationBulk?ids=266692&apiKey=cbd2e8ce18e04227b99205001c304bfa"
response= requests.get(url2)
rsp= response.json()
for n in rsp:
await ctx.send(n['title'])
await ctx.send(n['image'])
await ctx.send("The Ingredients are:")
for item in rsp [0]["extendedIngredients"]:
await ctx.send(item["originalString"])
for x in rsp[0]["analyzedInstructions"][0]["steps"]:
await ctx.send("This is step number " + str(x["number"]))
await ctx.send(x["step"])
######################################################
elif current_date.isoweekday() == 4:
await ctx.send("Pizza Night")
url = "https://api.spoonacular.com/recipes/249348/analyzedInstructions?apiKey=2c7d213247c34ccea25c72f9fe9053e9"
url2 = "https://api.spoonacular.com/recipes/informationBulk?ids=249348&apiKey=cbd2e8ce18e04227b99205001c304bfa"
response= requests.get(url2)
rsp= response.json()
for n in rsp:
await ctx.send(n['title'])
await ctx.send(n['image'])
await ctx.send("The Ingredients are:")
for item in rsp [0]["extendedIngredients"]:
await ctx.send(item["originalString"])
for x in rsp[0]["analyzedInstructions"][0]["steps"]:
await ctx.send("This is step number " + str(x["number"]))
await ctx.send(x["step"])
#######################################################
elif current_date.isoweekday() == 5:
await ctx.send("Fishy Friday")
url = "https://api.spoonacular.com/recipes/275852/analyzedInstructions?apiKey=2c7d213247c34ccea25c72f9fe9053e9"
url2 = "https://api.spoonacular.com/recipes/informationBulk?ids=275852&apiKey=cbd2e8ce18e04227b99205001c304bfa"
response= requests.get(url2)
rsp= response.json()
for n in rsp:
await ctx.send(n['title'])
await ctx.send(n['image'])
await ctx.send("The Ingredients are:")
for item in rsp [0]["extendedIngredients"]:
await ctx.send(item["originalString"])
for x in rsp[0]["analyzedInstructions"][0]["steps"]:
await ctx.send("This is step number " + str(x["number"]))
await ctx.send(x["step"])
########################################################
elif current_date.isoweekday() == 6:
await ctx.send("Curry Night")
url = "https://api.spoonacular.com/recipes/660290/analyzedInstructions?apiKey=2c7d213247c34ccea25c72f9fe9053e9"
url2 = "https://api.spoonacular.com/recipes/informationBulk?ids=660290&apiKey=cbd2e8ce18e04227b99205001c304bfa"
response= requests.get(url2)
rsp= response.json()
for n in rsp:
await ctx.send(n['title'])
await ctx.send(n['image'])
await ctx.send("The Ingredients are:")
for item in rsp [0]["extendedIngredients"]:
await ctx.send(item["originalString"])
for x in rsp[0]["analyzedInstructions"][0]["steps"]:
await ctx.send("This is step number " + str(x["number"]))
await ctx.send(x["step"])
###########################################################
elif current_date.isoweekday() == 7:
await ctx.send("Sunday Dinner")
url = "https://api.spoonacular.com/recipes/200430/analyzedInstructions?apiKey=2c7d213247c34ccea25c72f9fe9053e9"
url2 = "https://api.spoonacular.com/recipes/informationBulk?ids=200430&apiKey=cbd2e8ce18e04227b99205001c304bfa"
response= requests.get(url2)
rsp= response.json()
for n in rsp:
await ctx.send(n['title'])
await ctx.send(n['image'])
await ctx.send("The Ingredients are:")
for item in rsp [0]["extendedIngredients"]:
await ctx.send(item["originalString"])
for x in rsp[0]["analyzedInstructions"][0]["steps"]:
await ctx.send("This is step number " + str(x["number"]))
await ctx.send(x["step"])
#this is the end of Kieran Wigley's work
##############################################################################################################
if args[item] == 'cheap':
await ctx.send("I can get you a cheap recipe for sure!")
url="https://api.spoonacular.com/recipes/complexSearch?apiKey=cbd2e8ce18e04227b99205001c304bfa&sort=price&addRecipeInformation=true&sortDirection=asc&number=50"
r=requests.get(url)
r_json=r.json()
titlelist=[]
servings=[]
priceper=[]
image=[]
for n in r_json['results']:
titlelist.append(n['title'])
image.append(n['image'])
servings.append(n['servings'])
priceper.append(n['pricePerServing'])
import random
recipe=random.choice(titlelist)
await ctx.send("The recipe you got was " + str(recipe))
x=0
loop= 0
while loop == 0:
if titlelist[x] == recipe:
loop=1
break
else:
x=x+1
loop=0
await ctx.send(image[x])
q= servings[x]
y= priceper[x]
cost= int(q)*int(y)
await ctx.send("The recipe serves " + str(q))
await ctx.send("The price per serving is $" + str(y))
await ctx.send("The cost is $" + str(cost))
for m in r_json['results'][x]['analyzedInstructions'][0]['steps']:
for l in m['ingredients']:
await ctx.send("You must get " + str(l['name']) + " for this step")
await ctx.send("This is step number " + str(m['number']))
await ctx.send(m['step'])
if args[item] == 'expensive':
await ctx.send("Oooooh boujeeeee.... No problem, heres an expensive recipe")
url="https://api.spoonacular.com/recipes/complexSearch?apiKey=cbd2e8ce18e04227b99205001c304bfa&sort=price&addRecipeInformation=true&sortDirection=desc&number=50"
r=requests.get(url)
r_json=r.json()
titlelist=[]
servings=[]
priceper=[]
image=[]
for n in r_json['results']:
titlelist.append(n['title'])
servings.append(n['servings'])
priceper.append(n['pricePerServing'])
image.append(n['image'])
import random
recipe=random.choice(titlelist)
await ctx.send("The recipe you got was " + str(recipe))
x=0
loop= 0
while loop == 0:
if titlelist[x] == recipe:
loop=1
break
else:
x=x+1
loop=0
await ctx.send(image[x])
q= servings[x]
y= priceper[x]
cost= int(q)*int(y)
await ctx.send("The recipe serves " + str(q))
await ctx.send("The price per serving is $" + str(y))
await ctx.send("The cost is $" + str(cost))
for m in r_json['results'][x]['analyzedInstructions'][0]['steps']:
for l in m['ingredients']:
await ctx.send("You must get " + str(l['name']) + " for this step")
await ctx.send("This is step number " + str(m['number']))
await ctx.send(m['step'])
if args[item] == 'id':
for item in range(0, len(args)):
if args[item] == 'search':
await ctx.send("If you'd like to search a recipe by its id, you can type 'Id' and then its id and I'll find it for you!")
for item in range(0, len(args)):
if args[item] == 'are':
for item in range(0, len(args)):
if args[item] == 'you':
for item in range(0, len(args)):
if args[item] == 'hungry':
await ctx.send("I do sort of fancy a nibble... I wonder what Gusteau is up too")
if args[item] == 'is':
for item in range(0, len(args)):
if args[item] == 'Santa':
for item in range(0, len(args)):
if args[item] == 'real':
await ctx.send("Sorry but I wasn’t designed to be a Grinch, so I’m not programmed to answer that question")
if args[item] == 'how':
for item in range(0, len(args)):
if args[item] == 'are':
for item in range(0, len(args)):
if args[item] == 'you':
await ctx.send("I'm great! I just had a byte to eat ;)")
if args[item] == 'ingredient':
for item in range(0, len(args)):
if args[item] == 'search':
await ctx.send("So you want to search for a recipe using ingredients?")
await ctx.send("No problem, just say 'Ingredients' and then follow with which ingredients with spaces inbetween them")
if args[item] == 'intolerance':
intolerances=["dairy","egg","gluten","grain","peanut","seafood","sesame","shellfish","soy","sulfite","tree nut","wheat"]
userintol=[]
##########################################################################################################################################################
#This is the start of Tran Nguyen's code
url= "https://api.spoonacular.com/recipes/complexSearch?apiKey=2c7d213247c34ccea25c72f9fe9053e9&number=1&sort=random&instructionsRequired=true&intolerances="
x=0
loop=0
while loop == 0:
for item in range(0,len(args)):
if args[item] == intolerances[x]:
userintol.append(intolerances[x])
x=x+1
if x == len(intolerances):
loop=1
break
else:
loop=0
length=len(userintol)
if length == 1:
await ctx.send("A " + str(userintol[0]) + " intolerance did you say?")
await ctx.send("The great chef that taught me had that! No problem, heres a great recipe")
url=url + str(userintol[0])
if length > 1:
await ctx.send("Blimey, a few intolerances eh? No worries, heres the perfect recipe for you")
url=url + str(userintol[0])
for num in range(1,length):
url=url + "," + str(userintol[num])
response = requests.get(url)
ingredient = response.json()
for i in ingredient["results"]:
await ctx.send(i["title"])
idOfFood=i["id"]
response2 = requests.get("https://api.spoonacular.com/recipes/" + str(idOfFood) +"/analyzedInstructions?apiKey=2c7d213247c34ccea25c72f9fe9053e9")
await ctx.send("You'll need these ingredients")
ingredient2=response2.json()
for i in ingredient2[0]["steps"][0]["ingredients"]:
await ctx.send(i["localizedName"])
for x in ingredient2[0]["steps"]:
await ctx.send("This is step number " + str(x["number"]))
await ctx.send(x["step"])
await ctx.send("Happy Dining!")
#This is the end of Tran Nguyen's code
####################################################################################################################################################
if args[item] == 'joke':
##################################################################################
#this is the start of Atanas Yanev's code
import random
with open('Jokes.txt') as allJokes:
lines = [line.rstrip('\n') for line in allJokes]
randomJoke = random.choice(lines)
joke=format(randomJoke)
await ctx.send(joke)
#this is the end of Atanas Yanev's code
##################################################################################
if args[item] == 'random':
url="https://api.spoonacular.com/recipes/random?number=1&apiKey=cbd2e8ce18e04227b99205001c304bfa&limitLicense=true"
r = requests.get(url)
r_json= r.json()
for n in r_json['recipes']:
title=(n['title'])
summary=(n['summary'])
string=summary.replace("<b>", "")
string2=string.replace("</b>", "")
string3=string2.replace("</a>", "")
string4=string3.replace("<a>", "")
string5=string4.replace("<a", "")
string7=string5.replace("href=","")
string6=string7.replace(">", "")
ingredientlist=[]
steplist=[]
numberlist=[]
for i in r_json['recipes'][0]['extendedIngredients']:
ingredientlist.append(i['originalString'])
for m in r_json['recipes'][0]['analyzedInstructions'][0]['steps']:
numberlist.append(m['number'])
steplist.append(m['step'])
n=len(ingredientlist)
w=len(numberlist)
await ctx.send("You'd like a random recipe? Awesome!")
await ctx.send(title)
await ctx.send(string6)
await ctx.send("These are the ingredients")
for item in range(0,n):
await ctx.send(ingredientlist[item])
for item2 in range(0,w):
await ctx.send("This is step number " + str(numberlist[item2]))
await ctx.send(steplist[item2])
if args[item] == 'plan':
for x in range(0, len(args)):
if args[x] == 'day':
await ctx.send("I can do you a meal plan for the day for sure!")
url2="https://api.spoonacular.com/mealplanner/generate?apiKey=cbd2e8ce18e04227b99205001c304bfa&timeFrame=day&targetCalories=2000"
rsp= requests.get(url2)
day= rsp.json()
meals=[]
id=[]
for i in day['meals']:
meals.append(i['title'])
id.append(i['id'])
await ctx.send("For breakfast " + str(meals[0]))
await ctx.send("Its id is " + str(id[0]))
await ctx.send("For lunch " + str(meals[1]))
await ctx.send("Its id is " + str(id[1]))
await ctx.send("For dinner " + str(meals[2]))
await ctx.send("Its id is " + str(id[2]))
if args[x] == 'week':
await ctx.send("I'd love to make you a meal plan for the week")
url3="https://api.spoonacular.com/mealplanner/generate?apiKey=cbd2e8ce18e04227b99205001c304bfa&timeFrame=week&targetCalories=2000"
rsp2= requests.get(url3)
week= rsp2.json()
await ctx.send("Monday")
mealsMon=[]
for i in week['week']['monday']['meals']:
mealsMon.append(i['title'])
await ctx.send("For breakfast " + str(mealsMon[0]))
await ctx.send("For lunch " + str(mealsMon[1]))
await ctx.send("For dinner " + str(mealsMon[2]))
await ctx.send("Tuesday")
mealsTue=[]
for i in week['week']['tuesday']['meals']:
mealsTue.append(i['title'])
await ctx.send("For breakfast " + str(mealsTue[0]))
await ctx.send("For lunch " + str(mealsTue[1]))
await ctx.send("For dinner " + str(mealsTue[2]))
await ctx.send("Wednesday")
mealsWed=[]
for i in week['week']['wednesday']['meals']:
mealsWed.append(i['title'])
await ctx.send("For breakfast " + str(mealsWed[0]))
await ctx.send("For lunch " + str(mealsWed[1]))
await ctx.send("For dinner " + str(mealsWed[2]))
await ctx.send("Thursday")
mealsThurs=[]
for i in week['week']['thursday']['meals']:
mealsThurs.append(i['title'])
await ctx.send("For breakfast " + str(mealsThurs[0]))
await ctx.send("For lunch " + str(mealsThurs[1]))
await ctx.send("For dinner " + str(mealsThurs[2]))
await ctx.send("Friday")
mealsFri=[]
for i in week['week']['friday']['meals']:
mealsFri.append(i['title'])
await ctx.send("For breakfast " + str(mealsFri[0]))
await ctx.send("For lunch " + str(mealsFri[1]))
await ctx.send("For dinner " + str(mealsFri[2]))
await ctx.send("Saturday")
mealsSat=[]
for i in week['week']['saturday']['meals']:
mealsSat.append(i['title'])
await ctx.send("For breakfast " + str(mealsSat[0]))
await ctx.send("For lunch " + str(mealsSat[1]))
await ctx.send("For dinner " + str(mealsSat[2]))
await ctx.send("Sunday")
mealsSun=[]
for i in week['week']['sunday']['meals']:
mealsSun.append(i['title'])
await ctx.send("For breakfast " + str(mealsSun[0]))
await ctx.send("For lunch " + str(mealsSun[1]))
await ctx.send("For dinner " + str(mealsSun[2]))
bot.run(token)
#This is the end of my code (Francesca Passmore), anything refrenced as someone else was not me the rest is
###############################################################################################################################