From 7da1e01cd66449ea7855c3091c15a93993e7b6e6 Mon Sep 17 00:00:00 2001 From: gpkvt Date: Fri, 12 Aug 2022 12:40:00 +0200 Subject: [PATCH] Added option to start in TTS disabled state --- README.md | 6 +++++- config-dist.yml | 1 + tts.py | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e8fe4b9..3f0a02d 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ http: bind: "localhost" bot: + start_enabled: True subonly: False modonly: False message_length: 200 @@ -88,7 +89,8 @@ whitelist: * `bind`: Interface/IP to bind server to (e.g. localhost) ##### bot - + + * `start_enabled`: Enable the bot on start? If `False` you need to use `!ton` first to make TTS work. * `subonly`: If `True` only Subs can use TTS * `modonly`: If `True` only Mods can use TTS * `message_length`: Maximum allowed message length for TTS @@ -113,6 +115,8 @@ whitelist: * `level`: The loglevel, valid values are: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL` +Do not use `DEBUG` in a production environment. + ##### usermapping 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). diff --git a/config-dist.yml b/config-dist.yml index a83fc22..18e1f78 100644 --- a/config-dist.yml +++ b/config-dist.yml @@ -10,6 +10,7 @@ http: bind: "localhost" bot: + start_enabled: True subonly: False modonly: False message_length: 200 diff --git a/tts.py b/tts.py index cb6c4f9..dea5e3a 100644 --- a/tts.py +++ b/tts.py @@ -40,7 +40,7 @@ class IRC: self.irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.tts_denied = [] self.tts_allowed = [] - self.tts_status = True + self.tts_status = conf['TTS_STARTENABLED'] self.quickvote = False self.votemsg = False self.poll = {} @@ -267,6 +267,9 @@ class IRC: self.sendpriv(conf['IRC_CHANNEL'], "@"+str(user), conf['MESSAGE']['TOO_LONG']) return False + logging.debug("tts status: "+str(self.tts_status)) + logging.debug(conf['TTS_STARTENABLED']) + if not self.tts_status: logging.info('TTS is disabled') self.sendpriv(conf['IRC_CHANNEL'], "@"+str(user), conf['MESSAGE']['DISABLED']) @@ -429,6 +432,7 @@ def load_config(): conf['IRC_SUBONLY'] = cfg['bot']['subonly'] or False conf['IRC_MODONLY'] = cfg['bot']['modonly'] or False conf['IRC_TTS_LEN'] = cfg['bot']['message_length'] or 200 + conf['TTS_STARTENABLED'] = cfg['bot']['start_enabled'] or False conf['LOG_LEVEL'] = cfg['log']['level'] or "INFO" conf['HTTP_PORT'] = cfg['http']['port'] or 80