Move from new_chat_member.py to main.py

This commit is contained in:
hok7z 2023-02-07 10:26:33 +02:00
parent 46c11a893a
commit 1136f1eaf8
3 changed files with 25 additions and 28 deletions

View File

@ -1,3 +1,2 @@
from . import simple_admin from . import simple_admin
from . import main from . import main
from . import new_chat_member

View File

@ -4,6 +4,30 @@ import config
from database import Member from database import Member
@dp.message_handler(content_types=["new_chat_members"])
async def welcome_message(message: types.Message):
user = Member.get_or_none(Member.user_id == message.from_user.id)
if (user):
await message.answer(f"Hi, {user.first_name} again")
if not (user):
Member.create(
user_id=message.from_user.id,
first_name=message.from_user.first_name,
username=message.from_user.username,
)
await message.answer((
f"Hi, **{user.first_name}**!\n"
"Please, read [chat rules]({})"
).format("https://nometa.xyz"),
parse_mode="Markdown"
)
await message.delete()
@dp.message_handler( @dp.message_handler(
commands=["start", "help"], commands=["start", "help"],
chat_type=[types.ChatType.SUPERGROUP] chat_type=[types.ChatType.SUPERGROUP]
@ -62,7 +86,7 @@ async def get_information(message: types.Message):
@dp.message_handler( @dp.message_handler(
commands=["report2"], commands=["report"],
replied=True, replied=True,
chat_type=[types.ChatType.SUPERGROUP] chat_type=[types.ChatType.SUPERGROUP]
) )

View File

@ -1,26 +0,0 @@
from load import dp, types
from database import Member
@dp.message_handler(content_types=["new_chat_members"])
async def welcome_message(message: types.Message):
user = Member.get_or_none(Member.user_id == message.from_user.id)
if (user):
await message.answer(f"Hi, {user.first_name} again")
if not (user):
Member.create(
user_id=message.from_user.id,
first_name=message.from_user.first_name,
username=message.from_user.username,
)
await message.answer((
f"Hi, **{user.first_name}**!\n"
"Please, read [chat rules]({})"
).format("https://nometa.xyz"),
parse_mode="Markdown"
)
await message.delete()