async def get_chat_name(chat_id: int | str):
async with app:
chat = await app.get_chat(chat_id)
if chat.type == ChatType.PRIVATE:
return f'{chat.first_name} {chat.last_name}'
else:
return chat.title
import asyncio
from sqlite import SQL
db = SQL("test.db")
import userbot_options as ub
async def test():
chats = db.get_chats()
for chat_id in chats:
chat_name = await ub.get_chat_name(chat_id)
print(chat_name, chat_id)
asyncio.run(test())