Text#
- class aiogram.filters.text.Text(text: Optional[Union[Sequence[Union[str, LazyProxy]], str, LazyProxy]] = None, *, contains: Optional[Union[Sequence[Union[str, LazyProxy]], str, LazyProxy]] = None, startswith: Optional[Union[Sequence[Union[str, LazyProxy]], str, LazyProxy]] = None, endswith: Optional[Union[Sequence[Union[str, LazyProxy]], str, LazyProxy]] = None, ignore_case: bool = False)[source]#
Is useful for filtering text
aiogram.types.message.Message
, anyaiogram.types.callback_query.CallbackQuery
with data,aiogram.types.inline_query.InlineQuery
oraiogram.types.poll.Poll
question.Warning
Only one of text, contains, startswith or endswith argument can be used at once. Any of that arguments can be string, list, set or tuple of strings.
Deprecated since version 3.0: use magic-filter. For example do
F.text == "text"
instead- text#
- contains#
- startswith#
- endswith#
- ignore_case#
Can be imported:
from aiogram.filters.text import Text
from aiogram.filters import Text
Usage#
Text equals with the specified value:
Text(text="text") # value == 'text'
Text starts with the specified value:
Text(startswith="text") # value.startswith('text')
Text ends with the specified value:
Text(endswith="text") # value.endswith('text')
Text contains the specified value:
Text(contains="text") # value in 'text'
Any of previous listed filters can be list, set or tuple of strings that’s mean any of listed value should be equals/startswith/endswith/contains:
Text(text=["text", "spam"])
Ignore case can be combined with any previous listed filter:
Text(text="Text", ignore_case=True) # value.lower() == 'text'.lower()
Allowed handlers#
Allowed update types for this filter:
message
edited_message
channel_post
edited_channel_post
inline_query
callback_query