Last active
August 21, 2018 10:34
-
-
Save mizutori/6c947d786cf0240a3d279ec5e4d51d1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def process_event(event): | |
if event.type == EventType.ON_CONVERSATION_TURN_STARTED: | |
print() | |
print(event) | |
if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and | |
event.args and not event.args['with_follow_on_turn']): | |
print() | |
if event.type == EventType.ON_DEVICE_ACTION: | |
for command, params in event.actions: | |
print('Do command', command, 'with params', str(params)) | |
if command == "com.goldrushcomputing.commands.Move": | |
go_direction_str = params['go_direction'] | |
time = int( params['number'] ) | |
speed_str = params['speed'] | |
go_direction = 1 | |
if go_direction_str == 'BACKWARD': | |
go_direction = 2 | |
speed = 255 | |
if speed_str == 'SLOWLY': | |
speed = 140 | |
elif speed_str == 'NORMALLY': | |
speed = 200 | |
result = move(go_direction, time, speed) | |
elif command == "com.goldrushcomputing.commands.Turn": | |
direction_str = params['direction'] | |
direction = 0 | |
if direction_str == "LEFT": | |
direction = 1 | |
elif direction_str == "RIGHT": | |
direction = 0 | |
result = turn(direction) | |
elif command == "com.goldrushcomputing.commands.Hackathon": | |
result = hackathon() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment