123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- # █ █ ▀ █▄▀ ▄▀█ █▀█ ▀
- # █▀█ █ █ █ █▀█ █▀▄ █
- # © 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()
- ]
- )
|