From f5aaeaaf0a2a7ef75450772c433e6af20336b382 Mon Sep 17 00:00:00 2001 From: gpkvt Date: Thu, 11 Aug 2022 09:46:07 +0200 Subject: [PATCH] Strip @ from usernames for black/whitelist --- tts.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tts.py b/tts.py index 60ccc66..23ad5a2 100644 --- a/tts.py +++ b/tts.py @@ -31,7 +31,7 @@ class IRC: try: self.irc.connect((server, port)) except ConnectionResetError: - logging.fatal('Twitch refused to connect, please check your settings and try again (or just try again, as Twitch sometimes refuses to connect for no reason).') + logging.fatal('Twitch refused to connect, please check your settings and try again.') sys.exit(252) self.irc.settimeout(1) @@ -125,6 +125,10 @@ class IRC: if msg.startswith('!dtts'): logging.debug("!dtts command detected") user = msg.replace('!dtts', '').strip() + + if user.startswith('@'): + logging.debug('Removing "@" from username') + user = user.replace('@', '') if user not in self.tts_denied: logging.info("Adding "+str(user)+" to deny list") self.tts_denied.append(user) @@ -136,6 +140,10 @@ class IRC: logging.debug("!ptts command detected") user = msg.replace('!ptts', '').strip() + if user.startswith('@'): + logging.debug('Removing "@" from username') + user = user.replace('@', '') + self.tts_allowed.append(user) if user in self.tts_denied: