mirror of
https://github.com/nicolabs/nicobot.git
synced 2025-09-07 05:14:01 +02:00
+ allows disabling hello and goodbye if they're empty
~ fixed wrong log
This commit is contained in:
parent
bd817f3691
commit
1ecfe58f55
|
@ -348,8 +348,9 @@ class TransBot(Bot):
|
||||||
logging.debug("Found target language in message : %s"%to_lang)
|
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
|
# Case where the target language is not given ; we will simply use the current locale
|
||||||
else:
|
else:
|
||||||
logging.debug("Detected 'translate a message' case")
|
|
||||||
matched_translate = re.search( i18n.t('translate_default_locale'), message.strip(), flags=re.IGNORECASE )
|
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 ):
|
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 ):
|
def run( self ):
|
||||||
|
@ -422,7 +427,11 @@ class TransBot(Bot):
|
||||||
2. Waits for messages to translate
|
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.registerExitHandler()
|
||||||
self.chatter.start(self)
|
self.chatter.start(self)
|
||||||
|
|
||||||
|
|
|
@ -16,5 +16,8 @@ en:
|
||||||
# Key sentence that shuts the bot down
|
# Key sentence that shuts the bot down
|
||||||
Shutdown: bye nicobot
|
Shutdown: bye nicobot
|
||||||
|
|
||||||
|
# Set the following banners explicitely to the empty string "" to disable them
|
||||||
Hello: nicobot ready 🤟
|
Hello: nicobot ready 🤟
|
||||||
Goodbye: See you later 👋
|
Goodbye: See you later 👋
|
||||||
|
# Hello: ""
|
||||||
|
# Goodbye: ""
|
||||||
|
|
|
@ -16,5 +16,8 @@ fr:
|
||||||
# Phrase clé pour éteindre le bot
|
# Phrase clé pour éteindre le bot
|
||||||
Shutdown: couché nicobot
|
Shutdown: couché nicobot
|
||||||
|
|
||||||
|
# Remplacez ces messages par une chaîne vide "" afin de les désactiver
|
||||||
Hello: nicobot paré 🤟
|
Hello: nicobot paré 🤟
|
||||||
Goodbye: A+ 👋
|
Goodbye: A+ 👋
|
||||||
|
# Hello: ""
|
||||||
|
# Goodbye: ""
|
||||||
|
|
Loading…
Reference in a new issue