welcomecenterbot/src/handlers/handle_join_request.py

21 lines
677 B
Python
Raw Normal View History

2023-09-06 10:20:50 +00:00
from api import approve_chat_join_request, delete_message
from handlers.send_button import show_request_msg
from storage import Profile, storage
2023-04-23 16:54:58 +00:00
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:
# показываем сообщение с кнопкой "поручиться"
2023-04-28 12:24:14 +00:00
show_request_msg(msg)
2023-04-23 16:54:58 +00:00
else:
# за пользователя поручились ранее
r = approve_chat_join_request(chat_id, from_id)
print(r)
Profile.save(actor)