From feb272aeb11cc372ea731a46d38bacdec69995ff Mon Sep 17 00:00:00 2001 From: Jacob Henry Date: Sun, 3 Mar 2019 20:29:35 -0500 Subject: [PATCH] Better printing --- client.py | 5 ++++- slack_util.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/client.py b/client.py index 718cbf9..b1ace8f 100644 --- a/client.py +++ b/client.py @@ -4,6 +4,7 @@ import asyncio import json import sys import traceback +from pprint import pprint from typing import List, Any, AsyncGenerator, Dict, Coroutine, TypeVar from typing import Optional @@ -110,7 +111,8 @@ class ClientWrapper(object): # Get the payload post_params = await request.post() payload = json.loads(post_params["payload"]) - print("Interaction received: {}".format(payload)) + print("\nInteraction Event received:") + pprint(payload) # Handle each action separately if "actions" in payload: @@ -140,6 +142,7 @@ class ClientWrapper(object): # Respond that everything is fine return web.Response(status=200) else: + print("\nMalformed event received.") # If we can't read it, get mad return web.Response(status=400) diff --git a/slack_util.py b/slack_util.py index b12852c..2e4acbe 100644 --- a/slack_util.py +++ b/slack_util.py @@ -1,6 +1,7 @@ from __future__ import annotations from dataclasses import dataclass +from pprint import pprint from time import sleep from typing import Optional, Generator, Callable, Union, Awaitable from typing import TypeVar @@ -158,7 +159,8 @@ def message_stream(slack: SlackClient) -> Generator[Event, None, None]: # Handle each for update in update_list: - print("Message received: {}".format(update)) + print("\nRTM Message received:") + pprint(update) yield message_dict_to_event(update) except (SlackNotConnected, OSError) as e: