File size: 2,902 Bytes
21bc372 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#######################################################
# PRIVATE LICENSE NOTICE #
# © 2025 AKN-DEV. All Rights Reserved. #
# #
# This software is licensed under PRIVATE LICENSE. #
# Unauthorized use, modification, distribution, #
# or replication is strictly prohibited. #
# #
# LEGAL OWNER: AKN-DEV TEAM #
# CONTACT: @aknuserbot (Telegram) #
# #
# VIOLATIONS WILL RESULT IN: #
# - Automatic bot termination #
# - Legal action under DMCA/EU Copyright Law #
# - Permanent blacklist from all products #
#######################################################
import json
from pathlib import Path
from packaging import version
from akn.utils.logger import LOGS
import importlib.metadata
import platform
def get_version_from_file() -> str:
try:
with open(Path(__file__).parent.parent / "version.json") as f:
return json.load(f)["version"]
except Exception as e:
LOGS.critical(f"Version check failed: {str(e)}")
raise RuntimeError("Could not determine bot version") from e
def validate_version(bot_name: str) -> bool:
try:
version_file_path = Path(__file__).parent.parent / "version.json"
with open(version_file_path) as f:
version_data = json.load(f)
except Exception as e:
raise RuntimeError(f"Failed to load version.json: {str(e)}")
current_py = platform.python_version()
if version.parse(current_py) < version.parse(version_data["min_python"]):
raise RuntimeError(
f"Python {version_data['min_python']}+ required (found {current_py})"
)
bot_requirements = version_data.get("multiple_bot", {})
if bot_name not in bot_requirements:
return False, f"Bot '{bot_name}' not in version configuration"
required_ver = bot_requirements[bot_name]
current_ver = version_data["version"]
if not version.parse(current_ver) >= version.parse(required_ver.lstrip(">=")):
return False, f"Requires {required_ver} (current: {current_ver})"
try:
pyro_ver = importlib.metadata.version("kurigram")
if version.parse(pyro_ver) < version.parse("2.1.30"):
LOGS.warning(f"Old Pyrogram version: {pyro_ver}")
except ImportError:
pass
return True, "Version OK"
#######################################################
# DO NOT REMOVE THIS LICENSE NOTICE! #
# This code contains proprietary trade secrets of #
# AKN-DEV. Any removal will result in legal action. #
####################################################### |