xempire1 / bot /core /utils.py
yasir68's picture
Update bot/core/utils.py (#2)
234fc8e verified
raw
history blame
843 Bytes
import json
import requests
from functools import lru_cache
@lru_cache
def load_codes_from_files() -> dict:
url = "https://raw.githubusercontent.com/paveL1boyko/MuskEmpireBot/main/youtube.json"
response = requests.get(url)
response.raise_for_status() # Ensure we got a valid response
return response.json()
def num_prettier(num: int) -> str:
number = abs(num)
if number >= (comparer := 1e12):
prettier_num = f"{number / comparer:.1f}T"
elif number >= (comparer := 1e9):
prettier_num = f"{number / comparer:.1f}B"
elif number >= (comparer := 1e6):
prettier_num = f"{number / comparer:.1f}M"
elif number >= (comparer := 1e3):
prettier_num = f"{number / comparer:.1f}k"
else:
prettier_num = str(number)
return f"-{prettier_num}" if num < 0 else prettier_num