Пожалуйста, обратите внимание, что пользователь заблокирован
So i have been developing this telegram bot for carding methods, configs, accounts, ulp logs, and other various functions. However I am at a loss for why this function is not properly working.
This is the code I have. It is spose to be sending a message that is entered by the admin to all users in the bot_database.db
Any suggestions ?
This is the code I have. It is spose to be sending a message that is entered by the admin to all users in the bot_database.db
Python:
@router.callback_query(lambda c: c.data == "broadcast_all")
async def process_broadcast_option(callback: CallbackQuery, state: FSMContext):
try:
# Notify that the bot is ready to receive a message for broadcasting
await callback.message.answer("❗ Please enter the message you want to broadcast:")
await state.set_state(BroadcastStates.waiting_for_message)
await callback.answer() # Acknowledge the callback
except Exception as e:
logger.error(f"Error in broadcast option processing: {e}")
await callback.answer("An error occurred while processing your request.")
@router.message(StateFilter(BroadcastStates.waiting_for_message))
async def receive_broadcast_message(message: Message, state: FSMContext):
try:
# Store the message in state
await state.update_data(broadcast_message=message.text)
# Ask for confirmation
await message.answer(f"You entered: {message.text}\nDo you want to send this message? (yes/no)")
await state.set_state(BroadcastStates.waiting_for_confirmation)
except Exception as e:
logger.error(f"Error receiving broadcast message: {e}")
await message.answer("An error occurred while processing your message.")
@router.message(StateFilter(BroadcastStates.waiting_for_confirmation))
async def confirm_broadcast(message: Message, state: FSMContext):
user_response = message.text.lower()
if user_response == "yes":
data = await state.get_data()
broadcast_message = data.get("broadcast_message")
# Retrieve all user IDs from the database
users = await get_datax(database="storage_users", not_where=True, all=True)
total_users = len(users)
successful_sends = 0
failed_sends = 0
print(f"Starting broadcast to {total_users} users...")
# Iterate through users and send the message
for index, user in enumerate(users, start=1):
try:
await message.copy_to(chat_id=user['user_id'], reply_markup=mailer_buttons())
successful_sends += 1
print(f"\033[92mMessage sent to user ID: {user['user_id']} ({index}/{total_users})\033[0m") # Green
except Exception as e:
failed_sends += 1
print(f"\033[91mFailed to send message to user ID: {user['user_id']} ({index}/{total_users}): {e}\033[0m") # Red
# Add a small delay to avoid hitting rate limits
await asyncio.sleep(0.05)
# Send statistics back to admin
await message.answer(f'Mailing statistics:\n\n✅ Sent: <code>{successful_sends}</code>/{total_users}\n🚫 Not sent: <code>{failed_sends}</code>')
elif user_response == "no":
await message.answer("Broadcast canceled.")
else:
await message.answer("Please respond with 'yes' or 'no'.")
await state.finish() # Reset the state after processing
Any suggestions ?