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.set_tracking_branch(origin.refs.master)
|
||||||
repo.heads.master.checkout(True)
|
repo.heads.master.checkout(True)
|
||||||
return repo
|
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
|
@staticmethod
|
||||||
def send_config_one(
|
def send_config_one(
|
||||||
mod: "Module",
|
mod: "Module",
|
||||||
db: "Database", # noqa: F821
|
db: "Database", # type: ignore
|
||||||
translator: "Translator" = None, # noqa: F821
|
translator: "Translator" = None, # type: ignore
|
||||||
skip_hook: bool = False,
|
skip_hook: bool = False,
|
||||||
):
|
):
|
||||||
"""Send config to single instance"""
|
"""Send config to single instance"""
|
||||||
|
@ -703,8 +703,8 @@ class Modules:
|
||||||
async def send_ready_one(
|
async def send_ready_one(
|
||||||
self,
|
self,
|
||||||
mod: Module,
|
mod: Module,
|
||||||
client: "TelegramClient", # noqa: F821
|
client: "TelegramClient", # type: ignore
|
||||||
db: "Database", # noqa: F821
|
db: "Database", # type: ignore
|
||||||
allclients: list,
|
allclients: list,
|
||||||
no_self_unload: bool = False,
|
no_self_unload: bool = False,
|
||||||
from_dlmod: bool = False,
|
from_dlmod: bool = False,
|
||||||
|
|
|
@ -86,6 +86,9 @@ try:
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if "DYNO" in os.environ:
|
||||||
|
heroku.init()
|
||||||
|
|
||||||
|
|
||||||
def run_config(
|
def run_config(
|
||||||
db: database.Database,
|
db: database.Database,
|
||||||
|
|
|
@ -426,7 +426,7 @@ def merge(a: dict, b: dict) -> dict:
|
||||||
|
|
||||||
|
|
||||||
async def set_avatar(
|
async def set_avatar(
|
||||||
client: "TelegramClient", # noqa: F821
|
client: "TelegramClient", # type: ignore
|
||||||
peer: Entity,
|
peer: Entity,
|
||||||
avatar: str,
|
avatar: str,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
|
@ -454,7 +454,7 @@ async def set_avatar(
|
||||||
|
|
||||||
|
|
||||||
async def asset_channel(
|
async def asset_channel(
|
||||||
client: "TelegramClient", # noqa: F821
|
client: "TelegramClient", # type: ignore
|
||||||
title: str,
|
title: str,
|
||||||
description: str,
|
description: str,
|
||||||
*,
|
*,
|
||||||
|
@ -526,7 +526,7 @@ async def asset_channel(
|
||||||
|
|
||||||
|
|
||||||
async def dnd(
|
async def dnd(
|
||||||
client: "TelegramClient", # noqa: F821
|
client: "TelegramClient", # type: ignore
|
||||||
peer: Entity,
|
peer: Entity,
|
||||||
archive: Optional[bool] = True,
|
archive: Optional[bool] = True,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
|
@ -596,6 +596,10 @@ def get_named_platform() -> str:
|
||||||
is_okteto = "OKTETO" in os.environ
|
is_okteto = "OKTETO" in os.environ
|
||||||
is_docker = "DOCKER" in os.environ
|
is_docker = "DOCKER" in os.environ
|
||||||
is_lavhost = "LAVHOST" in os.environ
|
is_lavhost = "LAVHOST" in os.environ
|
||||||
|
is_heroku = "DYNO" in os.environ
|
||||||
|
|
||||||
|
if is_heroku:
|
||||||
|
return "♓️ Heroku"
|
||||||
|
|
||||||
if is_docker:
|
if is_docker:
|
||||||
return "🐳 Docker"
|
return "🐳 Docker"
|
||||||
|
@ -901,3 +905,31 @@ def get_lang_flag(countrycode: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
init_ts = time.perf_counter()
|
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