Advertisement
Mochinov

Untitled

Apr 4th, 2022
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1.  
  2.  
  3. @celery_app.task
  4. def delete_users(delete_user_id: int, manager_id: int) -> None:
  5.     """ Удаляет пользователя из чата """
  6.  
  7.     client = TelethonClient()
  8.  
  9.     chat_users = ChatUser.objects.filter(
  10.         id=delete_user_id,
  11.         is_delete=True,
  12.     )
  13.  
  14.     manager = User.objects.filter(id=manager_id).first()
  15.  
  16.     for user in chat_users:
  17.         if user.is_delete and user.user_deletion:
  18.             chat_tg_user = TgChatUser.objects.filter(
  19.                 tg_user__user = user.user,
  20.                 chat = user.chat,
  21.             )
  22.             User.objects.delete_user_from_chat(
  23.                 user=manager,
  24.                 chat_user=user,
  25.                 chat_tg_user=chat_tg_user,
  26.                 client=user,
  27.             )
  28.  
  29.     client.disconnect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement