Answer the question
In order to leave comments, you need to log in
AIOgram, what is the best way to update the mailing code so that it does not stop due to Flood control?
Initially, I wrote the code for the mailing list, but even with a small number of users in the mailing list, it stopped due to Flood control. Rewrote the mailing list as follows and increased the time out between messages:
...
for user in row:
try:
await bot.send_message(chat_id=user[0], text=data['mailing_text'])
except:
time.sleep(0.1)
...
Answer the question
In order to leave comments, you need to log in
Delimiter problem, try this:
DELIMITER |
CREATE TRIGGER `base`.`after_table`
AFTER INSERT ON `table` FOR EACH ROW BEGIN
INSERT INTO `table2` SET `name`='text';
END |
DELIMITER ;
Do not use time.sleep in asynchronous code, it will block the event loop! Instead, you should use the asynchronous version of asyncio.sleep.
In essence, with this code, 10 sends per second will be made, and officially the limit is 30 per second. But it would be better to additionally catch the exception with flood control and use it to do an additional sleep for at least 1 second, or even a little more, so that the counter of the number of attempts on the Telegram side is reset during this time.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question