1 from urllib.parse import parse_qs
2 from turbot.rot import rot
4 def turbot_lambda(event, context):
5 """Top-level entry point for our lambda function.
7 This parses the request and arguments and farms out to supporting
8 functions to implement all supported slash commands."""
10 body = parse_qs(event['body'])
11 command = body['command'][0]
12 args = body['text'][0]
14 if (command == "/rotlambda" or command == "/rot"):
15 return rot_slash_command(args)
17 error = "Command {} not implemented.".format(command)
19 print("Error: {}".format(error))
26 def rot_slash_command(args):
27 """Implementation of the /rot command
29 The args string should be as follows:
31 [count|*] String to be rotated
33 That is, the first word of the string is an optional number (or
34 the character '*'). If this is a number it indicates an amount to
35 rotate each character in the string. If the count is '*' or is not
36 present, then the string will be rotated through all possible 25
39 The result of the rotation is returned (with Slack formatting) in
40 the body of the response so that Slack will provide it as a reply
41 to the user who submitted the slash command."""