Strip @ from usernames for black/whitelist

This commit is contained in:
gpkvt 2022-08-11 09:46:07 +02:00
parent aa0ff1a129
commit b27b51b52f
2 changed files with 9 additions and 1 deletions

BIN
dist/tts.exe vendored

Binary file not shown.

10
tts.py
View File

@ -31,7 +31,7 @@ class IRC:
try: try:
self.irc.connect((server, port)) self.irc.connect((server, port))
except ConnectionResetError: 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) sys.exit(252)
self.irc.settimeout(1) self.irc.settimeout(1)
@ -125,6 +125,10 @@ class IRC:
if msg.startswith('!dtts'): if msg.startswith('!dtts'):
logging.debug("!dtts command detected") logging.debug("!dtts command detected")
user = msg.replace('!dtts', '').strip() user = msg.replace('!dtts', '').strip()
if user.startswith('@'):
logging.debug('Removing "@" from username')
user = user.replace('@', '')
if user not in self.tts_denied: if user not in self.tts_denied:
logging.info("Adding "+str(user)+" to deny list") logging.info("Adding "+str(user)+" to deny list")
self.tts_denied.append(user) self.tts_denied.append(user)
@ -136,6 +140,10 @@ class IRC:
logging.debug("!ptts command detected") logging.debug("!ptts command detected")
user = msg.replace('!ptts', '').strip() user = msg.replace('!ptts', '').strip()
if user.startswith('@'):
logging.debug('Removing "@" from username')
user = user.replace('@', '')
self.tts_allowed.append(user) self.tts_allowed.append(user)
if user in self.tts_denied: if user in self.tts_denied: