added utf8 support, limit messages length to prevent unexpected disconnects

This commit is contained in:
Antoine Pietri authored and Ammar Askar committed 2013-01-31 20:44:43 +05:00
1 parent 4988ab6ae1
commit 7e993237e3
3 files changed
+10 -11

No files matched your search

+3 -4
View File
@@ -5,6 +5,7 @@ import traceback
import threading
import hashlib
import string
import unicodedata
import Utils
import sys
from networking import PacketSenderManager
@@ -194,12 +195,10 @@ class PacketListener(threading.Thread):
print "Logged in \o/ Received an entity id of " + str(packet['EntityID'])
elif (response == "\x03"):
packet = PacketListenerManager.handle03(self.FileObject)
# Add "\x1b" because it is essential for ANSI escapes emitted by translate_escapes
if not self.connection.options.disableAnsiColours:
filtered_string = filter(lambda x: x in string.printable + "\x1b",
Utils.translate_escapes(packet['Message']))
filtered_string = Utils.translate_escapes(packet['Message'])
else:
filtered_string = filter(lambda x: x in string.printable, packet['Message'])
filtered_string = packet['Message']
print filtered_string
elif (response == "\x04"):