mirror of https://github.com/coddrago/Heroku
Add GeekTG compat; Continue integrating Heroku
parent
430868f5f7
commit
925b1caedd
|
@ -111,3 +111,9 @@ def get_repo():
|
|||
repo.heads.master.set_tracking_branch(origin.refs.master)
|
||||
repo.heads.master.checkout(True)
|
||||
return repo
|
||||
|
||||
|
||||
def init():
|
||||
"""Will be run on every Heroku start"""
|
||||
# Create repo if not found
|
||||
get_repo()
|
||||
|
|
|
@ -584,8 +584,8 @@ class Modules:
|
|||
@staticmethod
|
||||
def send_config_one(
|
||||
mod: "Module",
|
||||
db: "Database", # noqa: F821
|
||||
translator: "Translator" = None, # noqa: F821
|
||||
db: "Database", # type: ignore
|
||||
translator: "Translator" = None, # type: ignore
|
||||
skip_hook: bool = False,
|
||||
):
|
||||
"""Send config to single instance"""
|
||||
|
@ -703,8 +703,8 @@ class Modules:
|
|||
async def send_ready_one(
|
||||
self,
|
||||
mod: Module,
|
||||
client: "TelegramClient", # noqa: F821
|
||||
db: "Database", # noqa: F821
|
||||
client: "TelegramClient", # type: ignore
|
||||
db: "Database", # type: ignore
|
||||
allclients: list,
|
||||
no_self_unload: bool = False,
|
||||
from_dlmod: bool = False,
|
||||
|
|
|
@ -86,6 +86,9 @@ try:
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
if "DYNO" in os.environ:
|
||||
heroku.init()
|
||||
|
||||
|
||||
def run_config(
|
||||
db: database.Database,
|
||||
|
|
|
@ -426,7 +426,7 @@ def merge(a: dict, b: dict) -> dict:
|
|||
|
||||
|
||||
async def set_avatar(
|
||||
client: "TelegramClient", # noqa: F821
|
||||
client: "TelegramClient", # type: ignore
|
||||
peer: Entity,
|
||||
avatar: str,
|
||||
) -> bool:
|
||||
|
@ -454,7 +454,7 @@ async def set_avatar(
|
|||
|
||||
|
||||
async def asset_channel(
|
||||
client: "TelegramClient", # noqa: F821
|
||||
client: "TelegramClient", # type: ignore
|
||||
title: str,
|
||||
description: str,
|
||||
*,
|
||||
|
@ -526,7 +526,7 @@ async def asset_channel(
|
|||
|
||||
|
||||
async def dnd(
|
||||
client: "TelegramClient", # noqa: F821
|
||||
client: "TelegramClient", # type: ignore
|
||||
peer: Entity,
|
||||
archive: Optional[bool] = True,
|
||||
) -> bool:
|
||||
|
@ -596,6 +596,10 @@ def get_named_platform() -> str:
|
|||
is_okteto = "OKTETO" in os.environ
|
||||
is_docker = "DOCKER" in os.environ
|
||||
is_lavhost = "LAVHOST" in os.environ
|
||||
is_heroku = "DYNO" in os.environ
|
||||
|
||||
if is_heroku:
|
||||
return "♓️ Heroku"
|
||||
|
||||
if is_docker:
|
||||
return "🐳 Docker"
|
||||
|
@ -901,3 +905,31 @@ def get_lang_flag(countrycode: str) -> str:
|
|||
|
||||
|
||||
init_ts = time.perf_counter()
|
||||
|
||||
# GeekTG Compatibility
|
||||
def get_git_info():
|
||||
# https://github.com/GeekTG/Friendly-Telegram/blob/master/friendly-telegram/utils.py#L133
|
||||
try:
|
||||
repo = git.Repo()
|
||||
ver = repo.heads[0].commit.hexsha
|
||||
except Exception:
|
||||
ver = ""
|
||||
|
||||
return [
|
||||
ver,
|
||||
f"https://github.com/hikariatama/Hikka/commit/{ver}"
|
||||
if ver
|
||||
else "",
|
||||
]
|
||||
|
||||
|
||||
def get_version_raw():
|
||||
"""Get the version of the userbot"""
|
||||
# https://github.com/GeekTG/Friendly-Telegram/blob/master/friendly-telegram/utils.py#L128
|
||||
from . import version
|
||||
return ".".join(list(map(str, list(version.__version__))))
|
||||
|
||||
|
||||
get_platform_name = get_named_platform
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue