Text Triggers

class TextTriggers

Text-based triggers.

has_exact_word = <class 'gramhopper.triggers.text_triggers._HasExactWordTrigger'>

A word trigger. See more in _HasExactWordTrigger.

has_substring = <class 'gramhopper.triggers.text_triggers._HasSubstringTrigger'>

A substring trigger. See more in _HasSubstringTrigger.

regexp = <class 'gramhopper.triggers.text_triggers._RegExpTrigger'>

A regexp-based trigger. See more in _RegExpTrigger.

text.has_exact_word

class _HasExactWordTrigger(word: Union[str, List[str]])

Word trigger - the same as substring trigger, but for exact words search. This is used to trigger a rule when a certain word (or one of a list of words) exists in an incoming message.

__init__(word: Union[str, List[str]])

Constructs the trigger.

Parameters:word – The word/s to search in the message

text.has_substring

class _HasSubstringTrigger(substring: Union[str, List[str]], exact: bool = False)

Substring trigger. This is used to trigger a rule when a certain substring (or one of a list of substrings) exists in an incoming message.

__init__(substring: Union[str, List[str]], exact: bool = False)

Constructs the trigger.

Parameters:
  • substring – The substring/s to search in the message
  • exact – Whether the exact substring should appear (as a whole word) in the message

text.regexp

class _RegExpTrigger(pattern: str)

Regular-expression-based trigger. This is used to trigger a rule when an incoming message matches the given pattern.

__init__(pattern: str)

Constructs the trigger.

Parameters:pattern – The pattern to test the message’s match with