forked from usacs/Self-Guided-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek2.py
More file actions
41 lines (32 loc) · 1.25 KB
/
week2.py
File metadata and controls
41 lines (32 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import discord
import asyncio
import requests
class MyClient(discord.Client):
async def on_ready(self):
print('Logged in as')
print(self.user.name)
print(self.user.id)
print('------')
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return
if message.content.startswith('!food'):
await message.channel.send("Getting food")
msg = message.content.split(" ")
if(len(msg) < 3):
await message.channel.send("not enough arguments")
else:
data = requests.get("https://rumobile.rutgers.edu/1/rutgers-dining.txt")
location = msg[1]
meal = msg[2]
data_json = data.json()
for i in data_json:
if location.lower() in i['location_name'].lower():
for j in i['meals']:
if meal.lower() in j['meal_name'].lower():
for k in j['genres']:
for s in k['items']:
await message.channel.send(s)
client = MyClient()
client.run('token')