Standard Conditions#

This module provides basic conditions.

class ExactMatch(**data)[source]#

Bases: BaseCondition

Check if last_request matches match.

If skip_none, will not compare None fields of match.

match: Union[Message, dict[dict], str[str]]#

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.

classmethod validate_match(value)[source]#
async call(ctx)[source]#

Implement this to create a custom function.

Return type:

bool

class HasText(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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[Union[AbsoluteNodeLabel, NodeLabel, Tuple[str[str], str[str]], List[List[str]], dict[dict]]]#

List of labels to find in the last labels.

Is initialized according to AbsoluteNodeLabelInitTypes.

last_n_indices: int#

Number of labels to check.

classmethod validate_labels(labels)[source]#
async call(ctx)[source]#

Implement this to create a custom function.

Return type:

bool

class HasCallbackQuery(**data)[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