In theory, the user should send a screenshot and he was limited to one screenshot until it is not approved for subsequent submissions by the owner of the bot, but why does not appear after the command list of users in which this restriction and with the buttons unlock, I understand that somewhere in the code with this no connection. I would be grateful if you can help. Code:
blocked_users = {}
photo_count = {}
@dp.message_handler(content_types=['photo'])
async def photo_handler(message: types.Message):
user_id = message.from_user.id
user_name = message.from_user.full_name
if user_id in photo_count:
await bot.send_message(user_id, "You have already sent a photo. Please wait for approval before sending another one.")
return
if user_id in blocked_users and blocked_users[user_id]:
await bot.send_message(user_id, "You are currently blocked from sending photos. Please wait for approval before sending another one.")
return
photo_count[user_id] = 1
photo_data = message.photo[-1].file_id
# Если пользователь только что отправил фото, добавьте его в список заблокированных
if user_id not in blocked_users:
blocked_users[user_id] = False
@dp.message_handler(commands=['blocked_users'])
async def list_blocked_users(message: types.Message):
if not blocked_users:
await bot.send_message(message.chat.id, "No users are currently blocked.")
return
user_list = "\n".join([f"{user_id}: {user_name}" for user_id, user_name in blocked_users.items() if blocked_users[user_id]])
keyboard = types.InlineKeyboardMarkup()
for user_id, user_name in blocked_users.items():
if blocked_users[user_id]:
keyboard.add(types.InlineKeyboardButton(f"Unblock {user_name}", callback_data=f"unblock:{user_id}"))
await bot.send_message(message.chat.id, f"Blocked users:\n{user_list}", reply_markup=keyboard)
@dp.callback_query_handler(lambda c: c.data.startswith('unblock:'))
async def unblock_user(query: types.CallbackQuery):
user_id = int(query.data.split(':')[1])
if user_id not in blocked_users or not blocked_users[user_id]:
await bot.answer_callback_query(query.id, text="User is not blocked.")
return
blocked_users[user_id] = False
await bot.answer_callback_query(query.id, text="User has been unblocked.")
await bot.send_message(user_id, "You are now allowed to send screenshots again. Please wait for approval before sending another one.")
`