-2

I am writing a telegram bot using aiogram. The bot will be used by a lot of people and the bot has an order module.

The task of this module is to create orders that must be closed on time.

For example, the bot requests the date and time the order was closed, the user enters the date: 2022-08-17 and the time: 19:00. Therefore, the order will have to close on 2022-08-17 at 19:00.

Again, we must take into account that there will be many such orders and I need some kind of optimized and asynchronous option for this task, thanks

CallMeStag
  • 5,467
  • 1
  • 7
  • 22
loldude
  • 1
  • 2
  • We do not do your homework for you. What exactly is your question? What have you tried? – Frank Yellin Aug 14 '22 at 18:33
  • @FrankYellin, I haven't tried anything because I don't know what would be best, so I'm asking people who have done it. I was thinking about using a library with an aioschedule or asyncio trigger. By the way, it's summer now, there is no homework, only work and self-development – loldude Aug 14 '22 at 18:41

1 Answers1

0

I still went the standard way and so far there are no complaints, I also heard about the aioschedule library, something like a trigger. I myself have not used it, but if anyone is interested, you can read

date = datetime.datetime.strptime((order.dateStart + ' ' + order.timeStart), '%d.%m.%Y %H:%M')
await asyncio.sleep(timedelta.total_seconds(date - datetime.now()))
# code to be executed after the timer
loldude
  • 1
  • 2