1
mirror of git://git.acid.vegas/scroll.git synced 2024-11-22 08:06:39 +00:00

Added error handling for .ascii img command

This commit is contained in:
Dionysus 2023-06-26 02:57:02 -04:00
parent 78ff35d4db
commit bd048ae332
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE

View File

@ -235,12 +235,16 @@ class Bot():
elif args[1] == 'img' and len(args) == 3: elif args[1] == 'img' and len(args) == 3:
url = args[2] url = args[2]
if url.startswith('https://') or url.startswith('http://'): if url.startswith('https://') or url.startswith('http://'):
content = urllib.request.urlopen(url).read() try:
ascii = await img2irc.convert(content, int(self.settings['png_width'])) content = urllib.request.urlopen(url).read()
if ascii: ascii = await img2irc.convert(content, int(self.settings['png_width']))
for line in ascii: except Exception as ex:
await self.sendmsg(chan, line) await self.irc_error(chan, 'failed to convert image', ex)
await asyncio.sleep(self.settings['msg']) else:
if ascii:
for line in ascii:
await self.sendmsg(chan, line)
await asyncio.sleep(self.settings['msg'])
elif msg == '.ascii list': elif msg == '.ascii list':
await self.sendmsg(chan, underline + color('https://raw.githubusercontent.com/ircart/ircart/master/ircart/.list', light_blue)) await self.sendmsg(chan, underline + color('https://raw.githubusercontent.com/ircart/ircart/master/ircart/.list', light_blue))
elif msg == '.ascii random': elif msg == '.ascii random':