from aiogram import types, Dispatcher

from bot_lib.bot_create import logger, some_cb
from bot_lib.settings import BTN_LIST
from keyboards.common_keyboards import get_text_and_buttons_inline


# @dp.message_handler(commands=['start'])
async def cmd_start(message: types.Message):
    logger.info(f"{message.from_user.username} (id: {message.from_user.id}) wrote: {message.text}")
    # send menu
    text, buttons = await get_text_and_buttons_inline(BTN_LIST, some_cb)
    await message.answer(text, reply_markup=buttons)

# @dp.message_handler(content_types=[types.ContentType.NEW_CHAT_MEMBERS, types.ContentType.LEFT_CHAT_MEMBER])
async def user_joined_chat(message: types.Message):
    logger.info(f"{message.from_user.username} (id: {message.from_user.id}) joined chat")
    text, buttons = await get_text_and_buttons_inline(BTN_LIST, some_cb)
    await message.answer(text, reply_markup=buttons)

def register_message_handlers(dp: Dispatcher):
    # Place your handlers here
    dp.register_message_handler(cmd_start, commands=['start'])
    dp.register_message_handler(user_joined_chat, content_types=[types.ContentType.NEW_CHAT_MEMBERS])