scroll- irc bot to play ascii art |
git clone git://git.acid.vegas/scroll.git |
Log | Files | Refs | Archive | README | LICENSE |
commit 9d120737c3af89b5f1a9b46adeb44f28c976509b
parent 24a3e1b1fc1d6f1449d7d385c055eb20da702aee Author: acidvegas <acid.vegas@acid.vegas> Date: Wed, 7 Jun 2023 00:59:52 -0400 Finally fixed character encoding issue not playing files with UTF-16 & other encodings Diffstat:
|
1 file changed, 5 insertions(+), 1 deletion(-) |
diff --git a/scroll.py b/scroll.py @@ -155,7 +155,11 @@ class Bot(): else: await self.action(chan, 'the ascii gods have chosen... ' + color(name, cyan)) for line in ascii: - await self.sendmsg(chan, line.decode(chardet.detect(line)['encoding']).replace('\n','').replace('\r','') + reset) + try: + line = line.decode().replace('\n','').replace('\r','') + else: + line = line.encode(chardet.detect(line)['encoding']).decode() # Get fucked UTF-16 + await self.sendmsg(chan, line + reset) await asyncio.sleep(throttle.message) else: await self.irc_error(chan, 'invalid name', name) |