Why does not the schedule?

Using a library aiogram to write a Telegram. bot.
async def msg():
 await bot.send_message(config.admin_id, 'test')

schedule.every(1).minutes.do(msg)
while True:
schedule.run_pending()
 time.sleep(1)

Sending messages does not work. What is my mistake?
April 19th 20 at 12:31
1 answer
April 19th 20 at 12:33
Because schedule does not work with coroutine.
Then how should I do the newsletter? - kristy33 commented on April 19th 20 at 12:36
@kristy33full code attach - Laisha94 commented on April 19th 20 at 12:39
@Laisha94, There are 1500 rows. And they do not belong to this piece of code. I just need to send a message, for example every day at 12:00. In this case, the message 'test' is referred to no one admin_id which is simply kept my id telegram. - kristy33 commented on April 19th 20 at 12:42
@kristy33in VK I write, there are a couple of ideas. - Laisha94 commented on April 19th 20 at 12:45
@kristy33, inside the coroutines to twist an infinite loop, falling asleep in each iteration at the desired intervals. It is possible to instruct the event loop to periodically call a function using call_later, where you will create a Tasca. You can try to apply some library type async-cron or aioschedule. - laisha_Block commented on April 19th 20 at 12:48
@laisha_Block, Oh, thank you for aioschedule - Laisha94 commented on April 19th 20 at 12:51
@laisha_Block,
async def job(message='stuff'):
 await bot.send_message(config.admin_id, 'test')
asyncio.sleep(1)

for i in range(1):
schedule.every(1).minutes.do(job)

loop = asyncio.get_event_loop()
while True:
loop.run_until_complete(schedule.run_pending())
 time.sleep(0.1)

As the mind is to push to the rest of the code worked? - kristy33 commented on April 19th 20 at 12:54
@kristy33, you also said that schedule will not work. In this piece of code literally two right lines, rest of it is just a meaningless combination of arabaca copy-paste. - laisha_Block commented on April 19th 20 at 12:57

Find more questions by tags TelegramBotsPython