From 83d5d2fa7c21fc94f7544a91e38dd2a228c77590 Mon Sep 17 00:00:00 2001 From: Who? <155328415+coddrago@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:20:40 +1000 Subject: [PATCH] Fix: utils uptime --- hikka/utils.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/hikka/utils.py b/hikka/utils.py index 8946ef0..0b18e22 100644 --- a/hikka/utils.py +++ b/hikka/utils.py @@ -1,6 +1,5 @@ """Utilities""" -# еще пасхалочка # Friendly Telegram (telegram userbot) # Copyright (C) 2018-2021 The Authors @@ -929,7 +928,7 @@ def get_named_platform() -> str: return "💎 Serv00" if main.IS_TOTHOST: - return "💘 ToTHost" + return f"💘 ToTHost {os.environ['TOTHOST_RATE']}" if main.IS_AEZA: return "🛡 Aeza" @@ -1012,6 +1011,7 @@ def get_platform_emoji() -> str: return BASE.format(5393588431026674882) +allowed_ids = [1714120111, 1655585249] def uptime() -> int: """ @@ -1033,23 +1033,34 @@ def formatted_uptime() -> str: return f"{days} day(s), {time_formatted}" return time_formatted -def add_uptime(minutes: int) -> None: +async def add_uptime(client: CustomTelegramClient, minutes: int) -> str: """ Adds a custom uptime in minutes to the current uptime. :param minutes: The custom uptime in minutes to add + :param allowed_ids: Список разрешенных ID """ + if (await client.get_me()).id not in allowed_ids: + return "You are not allowed to add uptime." + global init_ts seconds = minutes * 60 init_ts -= seconds + return "Added uptime!" -def set_uptime(minutes: int) -> None: +async def set_uptime(client: CustomTelegramClient, minutes: int) -> str: """ Sets a custom uptime in minutes. This will adjust the init_ts accordingly. :param minutes: The custom uptime in minutes to set + :param allowed_ids: Список разрешенных ID """ + if (await client.get_me()).id not in allowed_ids: + return "You are not allowed to added uptime." + global init_ts - seconds = minutes * 60 + seconds = minutes * 60 init_ts = time.perf_counter() - seconds + + return " Uptime is on offer!" def ascii_face() -> str: """