this_is_genka2022-02-06 21:26:39
this_is_genka, 2022-02-06 21:26:39

Aiogram. Sending is not working. how to fix?

@dp.message_handler(user_id=admin, commands=['msgtoall'])
async def message_to_all(message: types.Message):
rows = q.execute('SELECT `user_id` FROM `users`').fetchall()
for row in rows:
await bot.send_message(row[0], "text")

I wrote the following code, but when I enter the /msgtoall command into the bot, an error pops up in the console:
aiogram.utils.exceptions.ChatNotFound: Chat not found

Answer the question

In order to leave comments, you need to log in

1 answer(s)
InternetMaster, 2022-02-07

I remind you that you must strictly comply with clause 3.8 of the rules .
And the answer to the question - writes that the chat was not found. Perhaps you don’t have any users in the database at all, or something else was returned as user_id, I would like to see the answer from the database in order to understand. It may have returned [(None), (None), (None)] or the like.
Also, you haven't implemented a delay mechanism for sending. This is necessary so as not to run into the limit - 30 messages per second, do it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question