-
Мне в боте нужна админская команда которая будет делать рассылку всем пользователям (от админа) у меня был такой код на аиограм 2, пытаюсь переписать ничего не получается. Заранее спасибо. class MyForm(StatesGroup):
message = State()
@dp.message(Command("send_all"))
async def admin_command(message: types.Message):
user_id = message.from_user.id
if str(user_id) == str(admin_id):
await message.answer('Напишите сообщение для рассылки')
# Ожидаем ответ админа
@dp.message()
async def handle_message_for_broadcast(message: types.Message, state: FSMContext):
await state.set_state()
user_id = message.from_user.id
if user_id == admin_id:
# Получаем список всех пользователей
for user_id in ids:
# Отправляем сообщение каждому пользователю
await bot.send_message(user_id, message.text) |
Beta Was this translation helpful? Give feedback.
Answered by
Olegt0rr
Oct 16, 2023
Replies: 2 comments 3 replies
-
https://docs.aiogram.dev/en/dev-3.x/dispatcher/finite_state_machine/index.html |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Olegt0rr
-
Доброго времени суток, вопрос все ещё актуален ? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://docs.aiogram.dev/en/dev-3.x/dispatcher/finite_state_machine/index.html