This repository has been archived on 2024-07-28. You can view files and clone it, but cannot push or open issues or pull requests.
moderator-bot/handlers/groups/new_chat_member.py

27 lines
744 B
Python
Raw Normal View History

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()