set timewait to 1sec

This commit is contained in:
Daniel afx 2020-10-26 03:48:06 +02:00
parent a9e884c4fa
commit 494535800d

View file

@ -58,24 +58,28 @@ class ForestBot(pydle.Client):
admin = await self.is_admin(source) admin = await self.is_admin(source)
if admin: if admin:
await self.dumplog(target) await self.dumplog(target)
else:
await self.message(target, '] You are NOT an administrator. :('.format(source))
async def dumplog(self, target): async def dumplog(self, target):
sleep_time = 1
while True: while True:
msg = self.queue.get() msg = self.queue.get()
time.sleep(1) await asyncio.sleep(sleep_time)
await self.message(target, msg) await self.message(target, msg)
if len(msg) == 0: if len(msg) == 0:
break break
def run(self, *args, **kwargs): def run(self, *args, **kwargs):
self.queue = kwargs['extqueue'] self.queue = kwargs['extqueue']
""" Connect and run bot in event loop. """
#self.eventloop.run_until_complete(self.connect(*args, **kwargs)) loop = self.eventloop
self.eventloop.run_until_complete(self.connect(*args)) #loop.run_until_complete(self.connect(*args, **kwargs))
loop.run_until_complete(self.connect(*args))
try: try:
self.eventloop.run_forever() loop.run_forever()
finally: finally:
self.eventloop.stop() loop.stop()
def CnCApp(queue): def CnCApp(queue):
botnick = 'cnc_' + get_random_string(8) botnick = 'cnc_' + get_random_string(8)