-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
33 lines (26 loc) · 680 Bytes
/
test.py
File metadata and controls
33 lines (26 loc) · 680 Bytes
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
import datetime
def say(message):
print(' '.join(message))
def tell(message):
print(message[0])
print(' '.join(message[1:]))
def now(message):
return str(datetime.datetime.now())
commands_explode = {
'/now' : now,
}
commands = {
'/say' : say,
'/tell' : tell,
}
message = '/tell marc hello dear world. It is now /now and I\'m really cool about it /now /now'
message = message.split(' ')
copy = []
for i in reversed(message):
try:
copy.append(commands_explode[i](message))
except KeyError:
if i in commands:
commands[i](list(reversed(copy)))
else:
copy.append(i)