Just as for slash commands in the previous commit, this will help make
turbot/actions.py easier to maintain.
'statusCode': 200,
'body': 'OK'
}
+
+actions = {
+ "button": {
+ "new_hunt": new_hunt
+ }
+}
atype = action['type']
avalue = action['value']
- if atype == 'button' and avalue == 'new_hunt':
- return turbot.actions.new_hunt(payload)
+ if (
+ atype in turbot.actions.actions
+ and avalue in turbot.actions.actions[atype]
+ ):
+ return turbot.actions.actions[atype][avalue](payload)
return error("Unknown action of type/value: {}/{}".format(atype, avalue))
def turbot_slash_command(body):