s
This commit is contained in:
13
backend/avatar_assets.py
Normal file
13
backend/avatar_assets.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
AVATAR_BASE_URL = "https://minio.nomadro.cn/hackrobot/nomadcna/avatars"
|
||||
AVATAR_URLS = [f"{AVATAR_BASE_URL}/avatar-{index:02d}.jpg" for index in range(1, 33)]
|
||||
|
||||
|
||||
def avatar_for_index(index: int) -> str:
|
||||
return AVATAR_URLS[abs(int(index)) % len(AVATAR_URLS)]
|
||||
|
||||
|
||||
def avatar_for_name(name: str) -> str:
|
||||
seed = sum(ord(char) for char in (name or "NomadCNA"))
|
||||
return avatar_for_index(seed)
|
||||
Reference in New Issue
Block a user