mirror of
https://git.wownero.com/dsc/craiyon-irc.git
synced 2024-08-15 01:03:24 +00:00
Fix author queue stuck
This commit is contained in:
parent
3f5977aa83
commit
0fc93a0192
1 changed files with 8 additions and 2 deletions
10
main.py
10
main.py
|
@ -200,6 +200,10 @@ async def main():
|
||||||
global TASK_AUTHORS, TASK_QUEUE
|
global TASK_AUTHORS, TASK_QUEUE
|
||||||
bot.loop.create_task(bot.connect())
|
bot.loop.create_task(bot.connect())
|
||||||
|
|
||||||
|
def _lower_author_task_count(task_author):
|
||||||
|
TASK_AUTHORS.setdefault(task_author, 1)
|
||||||
|
TASK_AUTHORS[task_author] -= 1
|
||||||
|
|
||||||
# main loop
|
# main loop
|
||||||
while True:
|
while True:
|
||||||
random.shuffle(TASK_QUEUE._queue)
|
random.shuffle(TASK_QUEUE._queue)
|
||||||
|
@ -209,12 +213,14 @@ async def main():
|
||||||
images = await task.get_images()
|
images = await task.get_images()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
bot.send("PRIVMSG", target=task.channel, message=f"could not fetch images: {ex}")
|
bot.send("PRIVMSG", target=task.channel, message=f"could not fetch images: {ex}")
|
||||||
|
_lower_author_task_count(task.author)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
image = await task.process_images(images)
|
image = await task.process_images(images)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
bot.send("PRIVMSG", target=task.channel, message=f"could not process images: {ex}")
|
bot.send("PRIVMSG", target=task.channel, message=f"could not process images: {ex}")
|
||||||
|
_lower_author_task_count(task.author)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
image_bytes = BytesIO()
|
image_bytes = BytesIO()
|
||||||
|
@ -226,10 +232,10 @@ async def main():
|
||||||
url = await task.post_image(image_bytes)
|
url = await task.post_image(image_bytes)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
bot.send("PRIVMSG", target=task.channel, message=str(ex))
|
bot.send("PRIVMSG", target=task.channel, message=str(ex))
|
||||||
|
_lower_author_task_count(task.author)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
TASK_AUTHORS.setdefault(task.author, 1)
|
_lower_author_task_count(task.author)
|
||||||
TASK_AUTHORS[task.author] -= 1
|
|
||||||
|
|
||||||
bot.send("PRIVMSG", target=task.channel, message=f"{url} ({task.author})")
|
bot.send("PRIVMSG", target=task.channel, message=f"{url} ({task.author})")
|
||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
|
|
Loading…
Reference in a new issue