welcomecenterbot/bot/handlers/handle_join_request.py
2023-09-11 18:52:35 +03:00

21 lines
689 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from bot.api import approve_chat_join_request, delete_message
from bot.handlers.send_button import show_request_msg
from bot.storage import Profile, storage
def handle_join_request(msg):
print(f'handle join request {msg}')
chat_id = str(msg['chat']['id'])
from_id = str(msg['from']['id'])
actor = Profile.get(from_id, msg)
if len(actor['parents']) == 0:
# показываем сообщение с кнопкой "поручиться"
show_request_msg(msg)
else:
# за пользователя поручились ранее
r = approve_chat_join_request(chat_id, from_id)
print(r)
Profile.save(actor)