Always convert usernames to lowercase

This commit is contained in:
gpkvt 2022-08-11 20:04:01 +02:00
parent 21b33ae419
commit bb17fd5f22
2 changed files with 7 additions and 4 deletions

View File

@ -85,6 +85,8 @@ whitelist:
Use this section to define key:value pairs of usernames. The first value is the Twitch username, the second value is how the bot should pronouce the user, when reading the message. This is helpfull if you have regulars with numbers or strangs chars in the name. You can add new/change entries on the fly without restarting the bot (changes took up to 60 seconds). Use this section to define key:value pairs of usernames. The first value is the Twitch username, the second value is how the bot should pronouce the user, when reading the message. This is helpfull if you have regulars with numbers or strangs chars in the name. You can add new/change entries on the fly without restarting the bot (changes took up to 60 seconds).
Please note: The key (real username) MUST be lowercase.
### whitelist ### whitelist
You can add a whitelist section to `config.yml`, a whitelist will override any other settings like `subonly` and `modonly`. Only users on the whitelist are allowed to use `!tts`. Broadcasters and mods can temporarily add users (including themselfs) to the whitelist by using the `!ptts` command, though. You can add a whitelist section to `config.yml`, a whitelist will override any other settings like `subonly` and `modonly`. Only users on the whitelist are allowed to use `!tts`. Broadcasters and mods can temporarily add users (including themselfs) to the whitelist by using the `!ptts` command, though.
@ -100,6 +102,8 @@ whitelist:
To disable the whitelist remove it from `config.yml` completely. If you just leave `whitelist:` without entries, everyone must be whitelisted using `!ptts`. The permit is temporarily until the bot restarts or the user is removed from the (temporary) whitelist using `!dtts`. To disable the whitelist remove it from `config.yml` completely. If you just leave `whitelist:` without entries, everyone must be whitelisted using `!ptts`. The permit is temporarily until the bot restarts or the user is removed from the (temporary) whitelist using `!dtts`.
Please note: Usernames MUST be lowercase.
## Usage ## Usage
Execute `tts.exe` (or `tts.py` if you have Python installed), open the TTS webpage in your browser (the URL depends on your `bind` and `port` configuration, usually it's just http://localhost). Click the `Init` button at the button of the TTS webpage (you should hear `Init complete`). Execute `tts.exe` (or `tts.py` if you have Python installed), open the TTS webpage in your browser (the URL depends on your `bind` and `port` configuration, usually it's just http://localhost). Click the `Init` button at the button of the TTS webpage (you should hear `Init complete`).
@ -110,6 +114,5 @@ Additional commands (broadcaster and mods only) are:
* `!toff`: Turn TTS off (will also empty the current TTS queue) * `!toff`: Turn TTS off (will also empty the current TTS queue)
* `!ton`: Turn TTS back on * `!ton`: Turn TTS back on
* `!dtts <username>`: Disable TTS for the given user * `!dtts <username>`: Disable TTS for the given user
* `!ptts <username>`: Allow TTS for the given user * `!ptts <username>`: Allow TTS for the given user

6
tts.py
View File

@ -109,7 +109,7 @@ class IRC:
msgid = tag.rsplit('id=',1)[1] msgid = tag.rsplit('id=',1)[1]
logging.debug('Message ID: '+str(msgid)) logging.debug('Message ID: '+str(msgid))
if tag.startswith('display-name='): if tag.startswith('display-name='):
user = tag.rsplit('display-name=',1)[1] user = tag.rsplit('display-name=',1)[1].lower()
logging.debug('Username: '+str(user)) logging.debug('Username: '+str(user))
msg = resp.rsplit('PRIVMSG #',1)[1] msg = resp.rsplit('PRIVMSG #',1)[1]
@ -124,7 +124,7 @@ class IRC:
if 'broadcaster' in badges or 'moderator' in badges: if 'broadcaster' in badges or 'moderator' in badges:
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().lower()
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)
@ -134,7 +134,7 @@ class IRC:
if msg.startswith('!ptts'): if msg.startswith('!ptts'):
logging.debug("!ptts command detected") logging.debug("!ptts command detected")
user = msg.replace('!ptts', '').strip() user = msg.replace('!ptts', '').strip().lower()
self.tts_allowed.append(user) self.tts_allowed.append(user)