Strip only unicode control characters from messages

master
Nikola Forró 6 years ago
parent 198b49aa12
commit 6f7e917001

@ -1,6 +1,6 @@
import functools import functools
import re import re
import string import unicodedata
import irc.bot import irc.bot
@ -89,7 +89,7 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
def _process_message(self, connection, event): def _process_message(self, connection, event):
tags = {t['key']: t['value'] for t in event.tags} tags = {t['key']: t['value'] for t in event.tags}
message = ''.join([c for c in event.arguments[0] if c in string.printable]) message = ''.join([c for c in event.arguments[0] if not unicodedata.category(c).startswith('C')])
message = message.rstrip() message = message.rstrip()
send_response = functools.partial(self._send_response, connection, event) send_response = functools.partial(self._send_response, connection, event)
for pattern, action in self.patterns + self.supported_commands: for pattern, action in self.patterns + self.supported_commands:

Loading…
Cancel
Save