Guest User

Untitled

a guest
Nov 27th, 2023
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. def scheduled_daily_demotion_reset(context: CallbackContext):
  2. # Get all users group stat
  3. cursor.execute("SELECT user_id, group_status FROM users")
  4. gstats = cursor.fetchall()
  5.  
  6. update = Update
  7. # check each user's group_status
  8. for user_id, group_status in gstats:
  9. if group_status == 'out':
  10. # Remove user from the group if out
  11. chat_id = update.message.chat_id
  12. kick(user_id, chat_id, update, context)
  13.  
  14. # Command handler for /kick
  15. def kick(user_id, chat_id, update: Update, context: CallbackContext) -> None:
  16. # Remove user from the group if out
  17. context.bot.kick_chat_member(chat_id, user_id)
  18. update.message.reply_text(f"{user_id} have been removed from the group due to 'out' status.")
  19.  
  20. Error I get:
  21. chat_id = update.message.chat_id
  22. ^^^^^^^^^^^^^^^^^^^^^^
  23. AttributeError: 'member_descriptor' object has no attribute 'chat_id'
Advertisement
Add Comment
Please, Sign In to add comment