scroll- irc bot to play ascii art |
git clone git://git.acid.vegas/scroll.git |
Log | Files | Refs | Archive | README | LICENSE |
commit bd048ae3326b09f93f8c3847d1456c57252d988f
parent 78ff35d4db767825bfe8a14cde8ad5a0ba9c6ea9 Author: acidvegas <acid.vegas@acid.vegas> Date: Mon, 26 Jun 2023 02:57:02 -0400 Added error handling for .ascii img command Diffstat:
|
1 file changed, 10 insertions(+), 6 deletions(-) |
diff --git a/scroll.py b/scroll.py @@ -235,12 +235,16 @@ class Bot(): elif args[1] == 'img' and len(args) == 3: url = args[2] if url.startswith('https://') or url.startswith('http://'): - content = urllib.request.urlopen(url).read() - ascii = await img2irc.convert(content, int(self.settings['png_width'])) - if ascii: - for line in ascii: - await self.sendmsg(chan, line) - await asyncio.sleep(self.settings['msg']) + try: + content = urllib.request.urlopen(url).read() + ascii = await img2irc.convert(content, int(self.settings['png_width'])) + except Exception as ex: + await self.irc_error(chan, 'failed to convert image', ex) + else: + if ascii: + for line in ascii: + await self.sendmsg(chan, line) + await asyncio.sleep(self.settings['msg']) elif msg == '.ascii list': await self.sendmsg(chan, underline + color('https://raw.githubusercontent.com/ircart/ircart/master/ircart/.list', light_blue)) elif msg == '.ascii random': |