from typing import Dict, List, Union from driver.database.dblocal import db blacklist_chatdb = db.blacklistChat async def blacklisted_chats() -> list: chats = blacklist_chatdb.find({"chat_id": {"$lt": 0}}) return [ chat["chat_id"] for chat in await chats.to_list(length=1000000000) ] async def blacklist_chat(chat_id: int) -> bool: if not await blacklist_chatdb.find_one({"chat_id": chat_id}): await blacklist_chatdb.insert_one({"chat_id": chat_id}) return True return False async def whitelist_chat(chat_id: int) -> bool: if await blacklist_chatdb.find_one({"chat_id": chat_id}): await blacklist_chatdb.delete_one({"chat_id": chat_id}) return True return False