+ allows disabling hello and goodbye if they're empty

~ fixed wrong log
This commit is contained in:
nicobo 2020-05-15 00:52:26 +02:00
parent bd817f3691
commit 1ecfe58f55
No known key found for this signature in database
GPG key ID: 2581E71C5FA5285F
3 changed files with 18 additions and 3 deletions

View file

@ -348,8 +348,9 @@ class TransBot(Bot):
logging.debug("Found target language in message : %s"%to_lang)
# Case where the target language is not given ; we will simply use the current locale
else:
logging.debug("Detected 'translate a message' case")
matched_translate = re.search( i18n.t('translate_default_locale'), message.strip(), flags=re.IGNORECASE )
if matched_translate:
logging.debug("Detected 'translate a message' case")
###
#
@ -411,7 +412,11 @@ class TransBot(Bot):
def onExit( self ):
sent = self.chatter.send( i18n.t('all_messages',message=i18n.t('Goodbye')) )
goodbye = i18n.t('Goodbye')
if goodbye and goodbye.strip():
sent = self.chatter.send( i18n.t('all_messages',message=goodbye) )
else:
logging.debug("No 'Goodbye' text : nothing was sent")
def run( self ):
@ -422,7 +427,11 @@ class TransBot(Bot):
2. Waits for messages to translate
"""
self.chatter.send( i18n.t('all_messages',message=i18n.t('Hello')) )
hello = i18n.t('Hello')
if hello and hello.strip():
self.chatter.send( i18n.t('all_messages',message=hello) )
else:
logging.debug("No 'Hello' text : nothing was sent")
self.registerExitHandler()
self.chatter.start(self)

View file

@ -16,5 +16,8 @@ en:
# Key sentence that shuts the bot down
Shutdown: bye nicobot
# Set the following banners explicitely to the empty string "" to disable them
Hello: nicobot ready 🤟
Goodbye: See you later 👋
# Hello: ""
# Goodbye: ""

View file

@ -16,5 +16,8 @@ fr:
# Phrase clé pour éteindre le bot
Shutdown: couché nicobot
# Remplacez ces messages par une chaîne vide "" afin de les désactiver
Hello: nicobot paré 🤟
Goodbye: A+ 👋
# Hello: ""
# Goodbye: ""