2022-12-01 05:54:32 -05:00
|
|
|
from load import dp, types
|
|
|
|
from database import Member
|
|
|
|
|
2023-01-22 05:27:20 -05:00
|
|
|
|
2022-12-01 05:54:32 -05:00
|
|
|
@dp.message_handler(content_types=["new_chat_members"])
|
2023-01-22 05:27:20 -05:00
|
|
|
async def welcome_message(message: types.Message):
|
2022-12-01 05:54:32 -05:00
|
|
|
user = Member.get_or_none(Member.user_id == message.from_user.id)
|
|
|
|
|
|
|
|
if (user):
|
2022-12-25 09:17:05 -05:00
|
|
|
await message.answer(f"Hi, {user.first_name} again")
|
2022-12-01 05:54:32 -05:00
|
|
|
|
|
|
|
if not (user):
|
|
|
|
Member.create(
|
2023-01-22 05:27:20 -05:00
|
|
|
user_id=message.from_user.id,
|
|
|
|
first_name=message.from_user.first_name,
|
|
|
|
username=message.from_user.username,
|
2022-12-01 05:54:32 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
await message.answer((
|
2022-12-25 09:17:05 -05:00
|
|
|
f"Hi, **{user.first_name}**!\n"
|
|
|
|
"Please, read [chat rules]({})"
|
2023-01-22 05:27:20 -05:00
|
|
|
).format("https://nometa.xyz"),
|
|
|
|
parse_mode="Markdown"
|
|
|
|
)
|
2022-12-01 05:54:32 -05:00
|
|
|
|
|
|
|
await message.delete()
|