-
Notifications
You must be signed in to change notification settings - Fork 4
/
foodorder.py
103 lines (88 loc) · 2.36 KB
/
foodorder.py
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import urllib2
import time
import willie
foodorder = {}
source = ""
orderstate = 0
owner = ""
@willie.module.commands('orderstart')
def startorder(bot, trigger):
setsource(bot, trigger.group(2),trigger.nick)
def setsource(bot, restaurant, nick):
global source
global orderstate
global owner
if orderstate == 0:
source = restaurant
orderstate = 1
owner = nick
bot.say("Order with " + str(source) + " created")
elif orderstate == 1:
bot.say("Order already underway, please add your selections")
else:
bot.say("Order closed and being delivered")
@willie.module.commands('order')
def getsource(bot, trigger):
global source
if source != "":
bot.say("Order underway from: " + source)
else:
bot.say("No order currently active")
@willie.module.commands('orderadd')
def addtoorder(bot, trigger):
global foodorder
global orderstate
user = trigger.nick
stuff = trigger.group(2)
if orderstate == 1:
foodorder[user] = stuff
bot.say("Added " + user + "'s order")
else:
bot.say("Order already completed or no order underway")
@willie.module.commands('orderdel')
def delfromorder(bot, trigger):
global foodorder
global orderstate
user = trigger.nick
if orderstate == 1:
del foodorder[user]
botsay("Order cleared for " + user)
else:
bot.say("Order already completed or no order underway")
@willie.module.commands('myorder')
def myorder(bot, trigger):
global foodorder
if trigger.nick in foodorder.keys():
bot.say(trigger.nick + " - " + foodorder[trigger.nick])
else:
bot.say(trigger.nick + " has no order")
@willie.module.commands('orderfull')
def getwholeorder(bot, trigger):
global foodorder
global source
global owner
if owner == trigger.nick:
bot.say(source)
for k,v in foodorder.items():
bot.say(k + " - " + v)
else:
print("Sorry this is not your order, please ask " + owner)
@willie.module.commands('orderclear')
def clearorder(bot, trigger):
global owner
if owner == trigger.nick:
global foodorder
foodorder = {}
global source
source = ""
global orderstate
nick = ""
orderstate = 0
bot.say("Order has been cleared")
else:
bot.say("This is not your order, please ask " + owner)
@willie.module.commands('orderfinal')
def finalorder(bot, trigger):
global orderstate
orderstate = 2
bot.say("Order locked for delivery")