Skip to content

Commit

Permalink
Typing fix and optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMaster3558 committed Aug 16, 2023
1 parent c6400e1 commit 9cb111a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions aiointeractions/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ def __repr__(self) -> str:
except NameError:
none_function: Callable[[Any], None] = lambda r: None

PONG: Dict[str, int] = {'type': 1} # pong response

PONG: web.Response
data = dumps({'type': 1})
if isinstance(data, bytes):
PONG = web.Response(status=200, body=data)
elif isinstance(data, str):
PONG = web.Response(status=200, text=data)
else:
assert False


def get_latest_task(before_tasks: Set[asyncio.Task[Any]]) -> asyncio.Task[Any]:
Expand Down Expand Up @@ -173,7 +181,7 @@ async def interactions_handler(self, request: web.Request) -> web.Response:
self.client.dispatch('verified_interaction_request', request)
data = loads(body)
if data['type'] == 1: # ping
return web.Response(text=dumps(PONG))
return PONG

tasks = asyncio.all_tasks()
self.client._connection.parse_interaction_create(data)
Expand Down

0 comments on commit 9cb111a

Please sign in to comment.