import base64 import os def get_base64_image(path: str) -> str: """خواندن فایل عکس و تبدیل به base64""" if not os.path.exists(path): raise FileNotFoundError(f"Avatar not found: {path}") with open(path, "rb") as f: data = f.read() return base64.b64encode(data).decode("utf-8") # Define the mapping of source names to avatar file paths SOURCE_AVATAR_MAPPING = { "Khamenei": "images/bot_avatar.png", "Sistani": "images/bot_avatar1.png", "Golpaygani": "images/bot_avatar2.png" } BOT_AVATARS_BASE64 = { source: get_base64_image(path) for source, path in SOURCE_AVATAR_MAPPING.items() } USER_AVATAR = get_base64_image("images/user_avatar.png") css = ''' ''' # A function to generate the bot template with the correct base64 image def get_bot_template(avatar_base64: str) -> str: return f'''