Polished solution for #18

This commit is contained in:
Profitroll 2023-01-23 12:01:35 +01:00
parent f14e80856c
commit 1ce47b0aaf

View File

@ -40,11 +40,39 @@ async def filter_join(app: Client, member: ChatMemberUpdated):
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {application['application'][question]}")
i += 1
await app.send_message(configGet("users", "groups"), locale("joined_application", "messages").format(member.from_user.first_name, member.from_user.username, "\n".join(application_content)))
return
if await isAnAdmin(member.invite_link.creator.id):
logWrite(f"User {holo_user.id} joined destination group with link {holo_user.link} of an admin {member.invite_link.creator.id}")
application = col_applications.find_one({"user": holo_user.id})
if application is None:
return
application_content = []
i = 1
for question in application['application']:
if i == 2:
age = relativedelta(datetime.now(), application['application']['2'])
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {application['application']['2'].strftime('%d.%m.%Y')} ({age.years} р.)")
elif i == 3:
if application['application']['3']['countryCode'] == "UA":
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {application['application']['3']['name']}")
else:
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {application['application']['3']['name']} ({application['application']['3']['adminName1']}, {application['application']['3']['countryName']})")
else:
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {application['application'][question]}")
i += 1
await app.send_message(configGet("users", "groups"), locale("joined_application", "messages").format(member.from_user.first_name, member.from_user.username, "\n".join(application_content)))
return
logWrite(f"User {holo_user.id} joined destination group with stolen/unapproved link {holo_user.link}")