K
K
kkqqff2021-02-21 16:10:28
SQLite
kkqqff, 2021-02-21 16:10:28

How to make a newsletter in aiogram?

Unable to send newsletter to every registered user. Sent only to me as an admin.

@dp.message_handler(user_id=admin_id, commands=['tellall'])
    async def mailing(message: types.Message):
        users = db.select_all_users()
        for user in users:
            await bot.send_message(chat_id=message.from_user.id,
                                   text="Тестовая рассылка")
            await sleep(0.3)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2021-02-21
@hottabxp

Something seems to me that in a line

await bot.send_message(chat_id=message.from_user.id,
should be instead of message.from_user.id - user id from the database.
Let me guess - you get a message as many times as there are users in the database?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question