-
-def rot_slash_command(body, args):
- """Implementation of the /rot command
-
- The args string should be as follows:
-
- [count|*] String to be rotated
-
- That is, the first word of the string is an optional number (or
- the character '*'). If this is a number it indicates an amount to
- rotate each character in the string. If the count is '*' or is not
- present, then the string will be rotated through all possible 25
- values.
-
- The result of the rotation is returned (with Slack formatting) in
- the body of the response so that Slack will provide it as a reply
- to the user who submitted the slash command."""
-
- channel_name = body['channel_name'][0]
- response_url = body['response_url'][0]
- channel_id = body['channel_id'][0]
-
- result = rot(args)
-
- if (channel_name == "directmessage"):
- requests.post(response_url,
- json = {"text": result},
- headers = {"Content-type": "application/json"})
- else:
- slack_client.chat_postMessage(channel=channel_id, text=result)
-
- return {
- 'statusCode': 200,
- 'body': ""
- }