Standard Conditions#

This module provides basic conditions.

class ExactMatch(match, *, skip_none=True)[source]#

Bases: BaseCondition

Check if last_request matches match.

If skip_none, will not compare None fields of match.

match: Message#

Message to compare last request with.

Is initialized according to MessageInitTypes.

skip_none: bool#

Whether fields set to None in match should not be compared.

async call(ctx)[source]#

Implement this to create a custom function.

Return type:

bool

class HasText(text)[source]#

Bases: BaseCondition

Check if the text attribute of last_request contains text.

text: str#

Text to search for in the last request.

async call(ctx)[source]#

Implement this to create a custom function.

Return type:

bool

class Regexp(pattern, *, flags=0)[source]#

Bases: BaseCondition

Check if the text attribute of last_request contains pattern.

pattern: Union[str, Pattern]#

The RegExp pattern to search for in the last request.

flags: Union[int, RegexFlag]#

Flags to pass to re.compile.

property re_object: Pattern#

Compiled pattern.

async call(ctx)[source]#

Implement this to create a custom function.

Return type:

bool

class Any(*conditions)[source]#

Bases: BaseCondition

Check if any condition from the conditions list is True.

conditions: List[BaseCondition]#

List of conditions.

async call(ctx)[source]#

Implement this to create a custom function.

Return type:

bool

class All(*conditions)[source]#

Bases: BaseCondition

Check if all conditions from the conditions list is True.

conditions: List[BaseCondition]#

List of conditions.

async call(ctx)[source]#

Implement this to create a custom function.

Return type:

bool

class Negation(condition)[source]#

Bases: BaseCondition

Return the negation of the result of condition.

condition: BaseCondition#

Condition to negate.

async call(ctx)[source]#

Implement this to create a custom function.

Return type:

bool

Not#

Not is an alias for Negation.

class CheckLastLabels(*, flow_labels=None, labels=None, last_n_indices=1)[source]#

Bases: BaseCondition

Check if any label in the last last_n_indices of Context.labels is in labels or if its flow_name is in flow_labels.

flow_labels: List[str]#

List of flow names to find in the last labels.

labels: List[AbsoluteNodeLabel]#

List of labels to find in the last labels.

Is initialized according to AbsoluteNodeLabelInitTypes.

last_n_indices: int#

Number of labels to check.

async call(ctx)[source]#

Implement this to create a custom function.

Return type:

bool

class HasCallbackQuery(query_string)[source]#

Bases: BaseCondition

Check if last_request contains a CallbackQuery attachment with CallbackQuery.query_string matching HasCallbackQuery.query_string.

query_string: str#

Query string to find in last request’s attachments.

async call(ctx)[source]#

Implement this to create a custom function.

Return type:

bool