From 6f7e917001ce1d3a51fd35115e5a80621244ef5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Fri, 20 Jul 2018 11:38:13 +0200 Subject: [PATCH] Strip only unicode control characters from messages --- clients/twitch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/twitch.py b/clients/twitch.py index dc46997..6ee1ca1 100644 --- a/clients/twitch.py +++ b/clients/twitch.py @@ -1,6 +1,6 @@ import functools import re -import string +import unicodedata import irc.bot @@ -89,7 +89,7 @@ class TwitchClient(irc.bot.SingleServerIRCBot): def _process_message(self, connection, event): 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() send_response = functools.partial(self._send_response, connection, event) for pattern, action in self.patterns + self.supported_commands: