Ufoptg commited on
Commit
7ec7f9a
1 Parent(s): 61e01ea

Update code2.py

Browse files
Files changed (1) hide show
  1. code2.py +5 -2
code2.py CHANGED
@@ -48,7 +48,7 @@ async def check_blacklist(event):
48
  f"User id: {user.id}, username: {user.username}"
49
  )
50
 
51
- # Get the chat admin permissions
52
  try:
53
  chat_admins = await client.get_participants(event.chat_id, filter=ChannelParticipantsAdmins)
54
  is_admin = any(admin.id == user.id for admin in chat_admins)
@@ -60,10 +60,12 @@ async def check_blacklist(event):
60
  try:
61
  await event.delete()
62
  logger.info("User is not an admin. Deleted the message.")
 
 
63
  await client.edit_permissions(
64
  entity=event.chat_id,
65
  user_id=user.id,
66
- view_messages=False
67
  )
68
  except Exception as e:
69
  logger.error("Failed to mute the user. Skipping action.")
@@ -83,6 +85,7 @@ async def check_blacklist(event):
83
  logger.info("Message does not contain a blacklisted word.")
84
 
85
 
 
86
  @client.on(events.CallbackQuery())
87
  async def handle_button(event):
88
  user = await event.get_sender()
 
48
  f"User id: {user.id}, username: {user.username}"
49
  )
50
 
51
+ # Check if the user is an admin
52
  try:
53
  chat_admins = await client.get_participants(event.chat_id, filter=ChannelParticipantsAdmins)
54
  is_admin = any(admin.id == user.id for admin in chat_admins)
 
60
  try:
61
  await event.delete()
62
  logger.info("User is not an admin. Deleted the message.")
63
+
64
+ # Mute the user by revoking their ability to send messages
65
  await client.edit_permissions(
66
  entity=event.chat_id,
67
  user_id=user.id,
68
+ send_messages=False
69
  )
70
  except Exception as e:
71
  logger.error("Failed to mute the user. Skipping action.")
 
85
  logger.info("Message does not contain a blacklisted word.")
86
 
87
 
88
+
89
  @client.on(events.CallbackQuery())
90
  async def handle_button(event):
91
  user = await event.get_sender()