-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
64 lines (52 loc) · 1.7 KB
/
run.py
File metadata and controls
64 lines (52 loc) · 1.7 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
import requests
import functions as func
from discord.ext import commands
from datetime import date, timedelta, datetime
PREFIX = os.getenv('PREFIX') or "!"
DISCORD_API_TOKEN = os.getenv('DISCORD_API_TOKEN')
bot = commands.Bot(command_prefix=PREFIX)
restaurants = {"fcup": 1, "feup": 3}
actions = {"help": func.getHelp,
"ajuda": func.getHelp,
"h": func.getHelp,
"hoje": func.getToday,
"hj": func.getToday,
"amanha": func.getTomorrow,
"am": func.getTomorrow,
"semana": func.getWeek,
"sem": func.getWeek,
}
@bot.event # on_ready
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.command()
async def multirest(ctx, *args):
instId = restaurants.get("fcup") #Default
instName = "fcup"
if len(args) == 0:
await ctx.send(func.invalidArg())
possible_args = list(actions.keys()) + list(restaurants.keys())
#get common elements between args and possible_args
common_args = [x for x in args if x in possible_args]
if len(common_args) == 1:
if common_args[0] in actions:
await ctx.send(actions[common_args[0]](instId, instName))
else:
await ctx.send(func.invalidArg())
elif len(common_args) == 2:
if "feup" in common_args:
instId = restaurants.get("feup")
instName = "feup"
for x in common_args:
if x in actions:
await ctx.send(actions[x](instId, instName))
else:
pass
@bot.command()
async def mr(ctx, *args):
await multirest(ctx, *args)
bot.run(DISCORD_API_TOKEN)