|
|
|
@ -204,6 +204,12 @@ async def main():
|
|
|
|
|
TASK_AUTHORS.setdefault(task_author, 1)
|
|
|
|
|
TASK_AUTHORS[task_author] -= 1
|
|
|
|
|
|
|
|
|
|
def _err(_task, err):
|
|
|
|
|
term = _task.term
|
|
|
|
|
if len(term) >= 12:
|
|
|
|
|
term = _task.term[:12] + ".."
|
|
|
|
|
return bot.send("PRIVMSG", target=_task.channel, message=f"{_task.author}: Error \"{term}\"; {err}")
|
|
|
|
|
|
|
|
|
|
# main loop
|
|
|
|
|
while True:
|
|
|
|
|
now = datetime.now()
|
|
|
|
@ -213,14 +219,14 @@ async def main():
|
|
|
|
|
try:
|
|
|
|
|
images = await task.get_images()
|
|
|
|
|
except Exception as ex:
|
|
|
|
|
bot.send("PRIVMSG", target=task.channel, message=f"could not fetch images: {ex}")
|
|
|
|
|
_err(task, err=f"Fetch: {ex}")
|
|
|
|
|
_lower_author_task_count(task.author)
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
image = await task.process_images(images)
|
|
|
|
|
except Exception as ex:
|
|
|
|
|
bot.send("PRIVMSG", target=task.channel, message=f"could not process images: {ex}")
|
|
|
|
|
_err(task, err=f"Process: {ex}")
|
|
|
|
|
_lower_author_task_count(task.author)
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
@ -232,14 +238,14 @@ async def main():
|
|
|
|
|
try:
|
|
|
|
|
url = await task.post_image(image_bytes)
|
|
|
|
|
except Exception as ex:
|
|
|
|
|
bot.send("PRIVMSG", target=task.channel, message=str(ex))
|
|
|
|
|
_err(task, err=f"uguu upload: {ex}")
|
|
|
|
|
_lower_author_task_count(task.author)
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
_lower_author_task_count(task.author)
|
|
|
|
|
|
|
|
|
|
completed_secs = (datetime.now() - now).total_seconds()
|
|
|
|
|
bot.send("PRIVMSG", target=task.channel, message=f"{url} \"{task.term}\" ({completed_secs}sec, {task.author}) ")
|
|
|
|
|
bot.send("PRIVMSG", target=task.channel, message=f"{url} \"{task.term}\" (total: {completed_secs}s, {task.author}) ")
|
|
|
|
|
await asyncio.sleep(10)
|
|
|
|
|
|
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
|