moe-serifu-agent icon indicating copy to clipboard operation
moe-serifu-agent copied to clipboard

Implement asyncio timer and deltimer commands

Open jghibiki opened this issue 6 years ago • 0 comments

Re-implement the existing C++ timer and deltimer commands

Design Details:

Timer command description:

  • schedules a timer to execute in the future
  • syntax: timer -r [time in ms] [command] e.g. timer -r 500 echo hello
  • the -r flag is optional, and causes the timer to repeat/reschedule
  • returns the id of the timer.

deltimer command description:

  • cancels an existing timer by id
  • syntax timer [timer id]

Design Notes:

  • to wait with asyncio, call await asyncio.sleep(2) to sleep 2 seconds. This is preferable to timer.sleep() as the timer method halts the thread.
  • consider asyncio.wait_for for waiting on the event queue with a timeout.
  • you should be able to use the TextInputEvent type to propagate the command text, and let the command module do the parsing and dispatching for you.

Done when:

  • A user can schedule a command and have it called after a given time period
  • A user can schedule a command to repeat every so often
  • A user can delete a timer by id.

jghibiki avatar Nov 13 '18 01:11 jghibiki