diff options
| author | 2024-01-29 18:13:43 +0800 | |
|---|---|---|
| committer | 2024-01-29 18:13:43 +0800 | |
| commit | 71d2cb27844699710a3976ee49347d6fc28dfcaa (patch) | |
| tree | 69187b77f1e37b4070809b62f5d924f75fa86ca8 | |
| parent | 04f687aae332fd2d94b76cfa22afd49b647f39f5 (diff) | |
| download | infini-71d2cb27844699710a3976ee49347d6fc28dfcaa.tar.gz infini-71d2cb27844699710a3976ee49347d6fc28dfcaa.zip | |
fix(router): add Command router
| -rw-r--r-- | src/infini/router.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/infini/router.py b/src/infini/router.py index 127f83be..c84e11a4 100644 --- a/src/infini/router.py +++ b/src/infini/router.py @@ -38,3 +38,17 @@ class Endswith(Router): def match(self, input: str) -> bool: input = input.strip() return any([input.endswith(sign) for sign in self.signs]) + + +class Command(Router): + type: Literal["command"] = "command" + prefix: tuple = (".", "/") + + def match(self, input: str) -> bool: + input = input.strip() + if input: + if input.startswith(self.prefix): + input = input[1:] + return any([input.startswith(sign) for sign in self.signs]) + + return False |
