Filter seemingly empty messages from random messages

This commit is contained in:
2020-12-19 13:09:57 +01:00
parent e101c81a1e
commit 92f5d30250
2 changed files with 11 additions and 1 deletions

8
lib/utils.py Normal file
View File

@@ -0,0 +1,8 @@
from collections import AsyncIterable
from typing import Callable, AsyncGenerator
async def async_filter(fun: Callable, iterable: AsyncIterable) -> AsyncGenerator:
async for val in iterable:
if fun(val):
yield val