Make do_append and do_stop optional in send_message_await_response_complex (#474)

This commit is contained in:
J. Nick Koston 2023-07-15 08:31:37 -10:00 committed by GitHub
parent 0a0172fa89
commit 0dbab1ebac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -598,8 +598,8 @@ class APIConnection:
async def send_message_await_response_complex(
self,
send_msg: message.Message,
do_append: Callable[[message.Message], bool],
do_stop: Callable[[message.Message], bool],
do_append: Optional[Callable[[message.Message], bool]],
do_stop: Optional[Callable[[message.Message], bool]],
msg_types: Iterable[Type[Any]],
timeout: float = 10.0,
) -> List[message.Message]:
@ -624,9 +624,9 @@ class APIConnection:
def on_message(resp: message.Message) -> None:
if fut.done():
return
if do_append(resp):
if do_append is None or do_append(resp):
responses.append(resp)
if do_stop(resp):
if do_stop is None or do_stop(resp):
fut.set_result(None)
for msg_type in msg_types:
@ -659,8 +659,8 @@ class APIConnection:
) -> Any:
res = await self.send_message_await_response_complex(
send_msg,
lambda msg: True, # we will only get responses of `response_type`
lambda msg: True, # we will only get responses of `response_type`
None, # we will only get responses of `response_type`
None, # we will only get responses of `response_type`
(response_type,),
timeout=timeout,
)