use asyncio.sleep instead of time.sleep in cron tasks
This commit is contained in:
parent
6da6769c25
commit
29d8ff41c5
1 changed files with 3 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
||||||
import time
|
import asyncio
|
||||||
import random
|
import random
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
@ -21,7 +21,8 @@ class Cron:
|
||||||
tokens = frozenset(job['tokens'].split(','))
|
tokens = frozenset(job['tokens'].split(','))
|
||||||
async def send_message() -> None:
|
async def send_message() -> None:
|
||||||
if 'rand' in job:
|
if 'rand' in job:
|
||||||
time.sleep(random.randint(0, job['rand']) * 60)
|
wait_seconds = random.randint(0, job['rand']) * 60
|
||||||
|
await asyncio.sleep(wait_seconds)
|
||||||
message = self.responder.get_response(tokens)
|
message = self.responder.get_response(tokens)
|
||||||
message = self.responder.api_match(message, '')
|
message = self.responder.api_match(message, '')
|
||||||
await self.client.send_message(job['chat'], message)
|
await self.client.send_message(job['chat'], message)
|
||||||
|
|
Loading…
Reference in a new issue