language_detection_processor#

class besser.bot.core.processors.language_detection_processor.LanguageDetectionProcessor(bot, user_messages=False, bot_messages=False)[source]#

Bases: Processor

The LanguageDetectionProcessor returns the spoken language in a given message.

This processor leverages the langdetect library to predict the language.

Parameters:
  • bot (Bot) – The bot the processor belongs to

  • user_messages (bool) – Whether the processor should be applied to user messages

  • bot_messages (bool) – Whether the processor should be applied to bot messages

bot#

The bot the processor belongs to

Type:

Bot

user_messages#

Whether the processor should be applied to user messages

Type:

bool

bot_messages#

Whether the processor should be applied to bot messages

Type:

bool

_abc_impl = <_abc._abc_data object>#
process(session, message)[source]#

Method to process a message and predict the message’s language.

The detected language will be stored as a session parameter. The key is “detected_language”.

Parameters:
  • session (Session) – the current session

  • message (str) – the message to be processed

Returns:

the processed message

Return type:

str