mirror of
https://git.wownero.com/dsc/craiyon-irc.git
synced 2024-08-15 01:03:24 +00:00
more context on failure
This commit is contained in:
parent
c215a6b9d5
commit
8e0defe3ca
1 changed files with 10 additions and 4 deletions
14
main.py
14
main.py
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue