From 8936a75c1a8761d866a45d0af473745694a3603a Mon Sep 17 00:00:00 2001 From: Who? <155328415+coddrago@users.noreply.github.com> Date: Thu, 26 Dec 2024 10:06:39 +0700 Subject: [PATCH] Delete hikka/modules/hikka_info.py --- hikka/modules/hikka_info.py | 168 ------------------------------------ 1 file changed, 168 deletions(-) delete mode 100644 hikka/modules/hikka_info.py diff --git a/hikka/modules/hikka_info.py b/hikka/modules/hikka_info.py deleted file mode 100644 index 1f3fbbe..0000000 --- a/hikka/modules/hikka_info.py +++ /dev/null @@ -1,168 +0,0 @@ -# ©️ Dan Gazizullin, 2021-2023 -# This file is a part of Hikka Userbot -# 🌐 https://github.com/hikariatama/Hikka -# You can redistribute it and/or modify it under the terms of the GNU AGPLv3 -# πŸ”‘ https://www.gnu.org/licenses/agpl-3.0.html - -import git -import time -from hikkatl.tl.types import Message -from hikkatl.utils import get_display_name - -from .. import loader, utils, version -from ..inline.types import InlineQuery -import subprocess - -@loader.tds -class HikkaInfoMod(loader.Module): - """Show userbot info""" - - strings = {"name": "HerokuInfo"} - - def __init__(self): - self.config = loader.ModuleConfig( - loader.ConfigValue( - "custom_message", - doc=lambda: self.strings("_cfg_cst_msg"), - ), - - loader.ConfigValue( - "banner_url", - "https://imgur.com/a/7LBPJiq.png", - lambda: self.strings("_cfg_banner"), - validator=loader.validators.Link(), - ), - ) - - def _render_info(self, inline: bool) -> str: - try: - repo = git.Repo(search_parent_directories=True) - diff = repo.git.log([f"HEAD..origin/{version.branch}", "--oneline"]) - upd = ( - self.strings("update_required") if diff else self.strings("up-to-date") - ) - except Exception: - upd = "" - - me = '{}'.format( - self._client.hikka_me.id, - utils.escape_html(get_display_name(self._client.hikka_me)), - ) - build = utils.get_commit_url() - _version = f'{".".join(list(map(str, list(version.__version__))))}' - prefix = f"Β«{utils.escape_html(self.get_prefix())}Β»" - - platform = utils.get_named_platform() - - for emoji, icon in [ - ("🍊", "🧑"), - ("πŸ‡", "πŸ’œ"), - ("πŸ˜Άβ€πŸŒ«οΈ", "πŸ˜Άβ€πŸŒ«οΈ"), - ("❓", "πŸ“±"), - ("πŸ€", "πŸ€"), - ("🦾", "🦾"), - ("πŸš‚", "πŸš‚"), - ("🐳", "🐳"), - ("πŸ•Ά", "πŸ“±"), - ("πŸˆβ€β¬›", "πŸˆβ€β¬›"), - ("✌️", "✌️"), - ("πŸ’Ž", "πŸ’Ž"), - ("πŸ›‘", "🌩"), - ("πŸ’˜", "πŸ’˜"), - ("🌼", " ❀️"), - ]: - platform = platform.replace(emoji, icon) - - return ( - ( - "πŸͺ Heroku\n" - if "heroku" not in self.config["custom_message"].lower() - else "" - ) - + self.config["custom_message"].format( - me=me, - version=_version, - build=build, - prefix=prefix, - platform=platform, - upd=upd, - uptime=utils.formatted_uptime(), - cpu_usage=utils.get_cpu_usage(), - ram_usage=f"{utils.get_ram_usage()} MB", - branch=version.branch, - hostname=subprocess.run(['hostname'], stdout=subprocess.PIPE).stdout.decode().strip(), - user=subprocess.run(['whoami'], stdout=subprocess.PIPE).stdout.decode().strip(), - ) - if self.config["custom_message"] - else ( - f'{{}}\n\n{{}} {self.strings("owner")}: {me}\n\n{{}}' - f' {self.strings("version")}: {_version} {build}\n{{}}' - f' {self.strings("branch")}:' - f" {version.branch}\n{upd}\n\n{{}}" - f' {self.strings("prefix")}: {prefix}\n{{}}' - f' {self.strings("uptime")}:' - f" {utils.formatted_uptime()}\n\n{{}}" - f' {self.strings("cpu_usage")}:' - f" ~{utils.get_cpu_usage()} %\n{{}}" - f' {self.strings("ram_usage")}:' - f" ~{utils.get_ram_usage()} MB\n{{}}" - ).format( - *map( - lambda x: utils.remove_html(x) if inline else x, - ( - ( - utils.get_platform_emoji() - if self._client.hikka_me.premium - else "πŸͺ Heroku" - ), - "😎", - "πŸ’«", - "🌳", - "⌨️", - "βŒ›οΈ", - "⚑️", - "πŸ’Ό", - platform, - ), - ) - ) - ) - - - async def info(self, _: InlineQuery) -> dict: - """Send userbot info""" - - return { - "title": self.strings("send_info"), - "description": self.strings("description"), - **( - {"photo": self.config["banner_url"], "caption": self._render_info(True)} - if self.config["banner_url"] - else {"message": self._render_info(True)} - ), - "thumb": ( - "https://github.com/hikariatama/Hikka/raw/master/assets/hikka_pfp.png" - ), - "reply_markup": self._get_mark(), - } - - @loader.command() - async def infocmd(self, message: Message): - await utils.answer_file( - message, - self.config["banner_url"], - self._render_info(False), - ) - - @loader.command() - async def hikkainfo(self, message: Message): - await utils.answer(message, self.strings("desc")) - - @loader.command() - async def setinfo(self, message: Message): - if not (args := utils.get_args_html(message)): - return await utils.answer(message, self.strings("setinfo_no_args")) - - self.config["custom_message"] = args - await utils.answer(message, self.strings("setinfo_success")) -