←︎ scroll :: 1d11796


1
commit 1d11796b4b34b2349596c9cfda158d4cc8276777 (HEAD -> master)
2
Author: acidvegas <acid.vegas@acid.vegas>
3
Date:   Mon Mar 23 18:47:59 2020 -0400
4
5
    Fixed decoding of utf16 files
6
---
7
 scroll/core/irc.py | 4 +++-
8
 1 file changed, 3 insertions(+), 1 deletion(-)
9
10
diff --git a/scroll/core/irc.py b/scroll/core/irc.py
11
index c69e602..1100472 100644
12
--- a/scroll/core/irc.py
13
+++ b/scroll/core/irc.py
14
@@ -2,6 +2,7 @@
15
 # Scroll IRC Art Bot - Developed by acidvegas in Python (https://acid.vegas/scroll)
16
 # irc.py
17
 
18
+import chardet
19
 import glob
20
 import os
21
 import random
22
@@ -94,7 +95,8 @@ class Commands:
23
 	def play(chan, ascii_file, trunc=None):
24
 		try:
25
 			Bot.playing = True
26
-			data = open(ascii_file, encoding='utf8', errors='replace').read()
27
+			data = open(ascii_file, 'rb').read()
28
+			data = data.decode(chardet.detect(data)['encoding'])
29
 			if len(data.splitlines()) > functions.floatint(database.Settings.get('max_lines')) and chan != '#scroll':
30
 				Commands.error(chan, 'File is too big.', 'Take it to #scroll')
31
 			else: