mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Add Bot API parser and code-generator
This commit is contained in:
parent
5e9d4e55d9
commit
af2573dbee
15 changed files with 3242 additions and 1 deletions
32
generator/consts.py
Normal file
32
generator/consts.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import re
|
||||
|
||||
DOCS_URL = "https://core.telegram.org/bots/api"
|
||||
|
||||
RE_FLAGS = re.IGNORECASE
|
||||
ANCHOR_HEADER_PATTERN = re.compile(r"^h([34])$")
|
||||
RETURN_PATTERNS = [
|
||||
re.compile(r"(?P<type>Array of [a-z]+) objects", flags=RE_FLAGS),
|
||||
re.compile(r"a (?P<type>[a-z]+) object", flags=RE_FLAGS),
|
||||
re.compile(r"Returns (?P<type>[a-z]+) on success", flags=RE_FLAGS),
|
||||
re.compile(r"(?P<type>[a-z]+) on success", flags=RE_FLAGS),
|
||||
re.compile(
|
||||
r"(?P<type>[a-z]+) is returned, otherwise (?P<other>[a-zA-Z]+) is returned", flags=RE_FLAGS
|
||||
),
|
||||
re.compile(
|
||||
r"returns the edited (?P<type>[a-z]+), otherwise returns (?P<other>[a-zA-Z]+)",
|
||||
flags=RE_FLAGS,
|
||||
),
|
||||
re.compile(r"(?P<type>[a-z]+) is returned", flags=RE_FLAGS),
|
||||
re.compile(r"Returns (?P<type>[a-z]+)", flags=RE_FLAGS),
|
||||
]
|
||||
BUILTIN_TYPES = {
|
||||
"String": "str",
|
||||
"Integer": "int",
|
||||
"Float": "float",
|
||||
"Boolean": "bool",
|
||||
"InputFile": "types.InputFile",
|
||||
}
|
||||
READ_MORE_PATTERN = re.compile(
|
||||
r" ((More info on|More about)([\W\w]+»)|»)", flags=re.MULTILINE & re.IGNORECASE
|
||||
)
|
||||
SYMBOLS_MAP = {"“": "'", "”": "'"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue