mirror of https://github.com/coddrago/Heroku
54 lines
2.0 KiB
Python
54 lines
2.0 KiB
Python
# █ █ ▀ █▄▀ ▄▀█ █▀█ ▀
|
|
# █▀█ █ █ █ █▀█ █▀▄ █
|
|
# © Copyright 2022
|
|
# https://t.me/hikariatama
|
|
#
|
|
# 🔒 Licensed under the GNU AGPLv3
|
|
# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
import re
|
|
|
|
|
|
def compat(code: str) -> str:
|
|
"""
|
|
Reformats modules, built for GeekTG to work with Hikka
|
|
:param code: code to reformat
|
|
:return: reformatted code
|
|
"""
|
|
return "\n".join(
|
|
[
|
|
re.sub(
|
|
r"^( *)from \.\.inline import (.+)$",
|
|
r"\1from ..inline.types import \2",
|
|
re.sub(
|
|
r"^( *)from \.\.inline import rand[^,]*$",
|
|
"\1from ..utils import rand",
|
|
re.sub(
|
|
r"^( *)from \.\.inline import rand, ?(.+)$",
|
|
r"\1from ..inline.types import \2\n\1from ..utils import rand",
|
|
re.sub(
|
|
r"^( *)from \.\.inline import (.+), ?rand[^,]*$",
|
|
r"\1from ..inline.types import \2\n\1from ..utils import"
|
|
r" rand",
|
|
re.sub(
|
|
r"^( *)from \.\.inline import (.+), ?rand, ?(.+)$",
|
|
r"\1from ..inline.types import \2, \3\n\1from ..utils"
|
|
r" import rand",
|
|
line.replace("GeekInlineQuery", "InlineQuery").replace(
|
|
"self.inline._bot",
|
|
"self.inline.bot",
|
|
),
|
|
flags=re.M,
|
|
),
|
|
flags=re.M,
|
|
),
|
|
flags=re.M,
|
|
),
|
|
flags=re.M,
|
|
),
|
|
flags=re.M,
|
|
)
|
|
for line in code.splitlines()
|
|
]
|
|
)
|