Allow to use regular values as the same with another sequences in filters

This commit is contained in:
Alex Root Junior 2020-01-15 23:34:33 +02:00
parent d37a7f0a0d
commit b144332287
9 changed files with 53 additions and 23 deletions

View file

@ -7,7 +7,7 @@ Works only with [Message](../../api/types/message.md) events which have the `tex
## Specification
| Argument | Type | Description |
| --- | --- | --- |
| `commands` | `#!python3 List[CommandPatterType]` | List of commands (string or compiled regexp patterns) |
| `commands` | `#!python3 Union[Sequence[Union[str, re.Pattern]], Union[str, re.Pattern]]` | List of commands (string or compiled regexp patterns) |
| `commands_prefix` | `#!python3 str` | Prefix for command. Prefix is always is single char but here you can pass all of allowed prefixes, for example: `"/!"` will work with commands prefixed by `"/"` or `"!"` (Default: `"/"`). |
| `commands_ignore_case` | `#!python3 bool` | Ignore case (Does not work with regexp, use flags instead. Default: `False`) |
| `commands_ignore_mention` | `#!python3 bool` | Ignore bot mention. By default bot can not handle commands intended for other bots (Default: `False`) |
@ -15,7 +15,7 @@ Works only with [Message](../../api/types/message.md) events which have the `tex
## Usage
1. Filter single variant of commands: `#!python3 Command(commands=["start"])`
1. Filter single variant of commands: `#!python3 Command(commands=["start"])` or `#!python3 Command(commands="start")`
1. Handle command by regexp pattern: `#!python3 Command(commands=[re.compile(r"item_(\d+)")])`
1. Match command by multiple variants: `#!python3 Command(commands=["item", re.compile(r"item_(\d+)")])`
1. Handle commands in public chats intended for other bots: `#!python3 Command(commands=["command"], commands)`

View file

@ -19,11 +19,11 @@ Or used from filters factory by passing corresponding arguments to handler regis
| Argument | Type | Description |
| --- | --- | --- |
| `content_types` | `#!python3 Optional[List[str]]` | List of allowed content types |
| `content_types` | `#!python3 Optional[Union[Sequence[str], str]]` | List of allowed content types |
## Usage
1. Single content type: `#!python3 ContentTypesFilter(content_types=["sticker"])`
1. Single content type: `#!python3 ContentTypesFilter(content_types=["sticker"])` or `#!python3 ContentTypesFilter(content_types="sticker")`
1. Multiple content types: `#!python3 ContentTypesFilter(content_types=["sticker", "photo"])`
1. Recommended: With usage of `ContentType` helper: `#!python3 ContentTypesFilter(content_types=[ContentType.PHOTO])`
1. Any content type: `#!python3 ContentTypesFilter(content_types=[ContentType.ANY])`

View file

@ -18,10 +18,10 @@ Or used from filters factory by passing corresponding arguments to handler regis
| Argument | Type | Description |
| --- | --- | --- |
| `text` | `#!python3 Optional[Union[str, List[str], Set[str], Tuple[str]]]` | Text equals value or one of values |
| `text_contains` | `#!python3 Optional[Union[str, List[str], Set[str], Tuple[str]]]` | Text contains value or one of values |
| `text_startswith` | `#!python3 Optional[Union[str, List[str], Set[str], Tuple[str]]]` | Text starts with value or one of values |
| `text_endswith` | `#!python3 Optional[Union[str, List[str], Set[str], Tuple[str]]]` | Text ends with value or one of values |
| `text` | `#!python3 Optional[Union[Sequence[str], str]]` | Text equals value or one of values |
| `text_contains` | `#!python3 Optional[Union[Sequence[str], str]]` | Text contains value or one of values |
| `text_startswith` | `#!python3 Optional[Union[Sequence[str], str]]` | Text starts with value or one of values |
| `text_endswith` | `#!python3 Optional[Union[Sequence[str], str]]` | Text ends with value or one of values |
| `text_ignore_case` | `#!python3 bool` | Ignore case when checks (Default: `#!python3 False`) |
!!! warning