This commit is contained in:
Jacob Henry 2019-03-02 23:45:56 -05:00
parent 63f03ad158
commit 6a9dbe9d86
2 changed files with 20 additions and 22 deletions

36
main.py
View File

@ -56,24 +56,24 @@ def main() -> None:
event_handling = wrap.handle_events() event_handling = wrap.handle_events()
passive_handling = wrap.run_passives() passive_handling = wrap.run_passives()
both = asyncio.gather(event_handling, passive_handling) both = asyncio.gather(event_handling, passive_handling)
#
wrap.send_message("test", "#botzone", blocks=[ # wrap.send_message("test", "#botzone", blocks=[
{ # {
"type": "actions", # "type": "actions",
"block_id": "test_block_id", # "block_id": "test_block_id",
"elements": [ # "elements": [
{ # {
"type": "button", # "type": "button",
"action_id": "test_action_id", # "action_id": "test_action_id",
"text": { # "text": {
"type": "plain_text", # "type": "plain_text",
"text": "Send payload", # "text": "Send payload",
"emoji": False # "emoji": False
} # }
} # }
] # ]
} # }
]) # ])
event_loop.run_until_complete(both) event_loop.run_until_complete(both)

View File

@ -275,11 +275,11 @@ class ClientWrapper(object):
async def interr(request: web.Request): async def interr(request: web.Request):
if request.can_read_body: if request.can_read_body:
# Get the payload # Get the payload
body_dict = await request.json()
payload = body_dict["payload"]
print("Got a normal request: {}".format(request)) print("Got a normal request: {}".format(request))
print(await request.read()) print(await request.read())
print("Interaction received: {}".format(payload)) print("Interaction received: {}".format(payload))
body_dict = await request.json()
payload = body_dict["payload"]
# Handle each action separately # Handle each action separately
if "actions" in payload: if "actions" in payload:
@ -306,8 +306,6 @@ class ClientWrapper(object):
# Respond that everything is fine # Respond that everything is fine
return web.Response(status=200) return web.Response(status=200)
else: else:
print("Got a weird request: {}".format(request))
print(await request.read())
# If we can't read it, get mad # If we can't read it, get mad
return web.Response(status=400) return web.Response(status=400)