From 9d120737c3af89b5f1a9b46adeb44f28c976509b Mon Sep 17 00:00:00 2001 From: acidvegas Date: Wed, 7 Jun 2023 00:59:52 -0400 Subject: [PATCH] Finally fixed character encoding issue not playing files with UTF-16 & other encodings --- scroll.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scroll.py b/scroll.py index a4e05c6..b002ee7 100644 --- 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)