import logging

from pyrogram import filters
from pyrogram.types import Message

from classes.pyroclient import PyroClient
from classes.pyrogroup import PyroGroup

logger = logging.getLogger(__name__)


@PyroClient.on_message(filters.new_chat_members & filters.group & filters.me)  # type: ignore
async def handler_bot_join(app: PyroClient, message: Message):
    logger.info("Bot has joined the group %s")
    await PyroGroup.create_if_not_exists(message.chat.id, None, True)
