AIDA / scripts /update_aida_avatar.py
destinyebuka's picture
fyp
f062490
#!/usr/bin/env python3
"""
Script to update AIDA_BOT avatar with the uploaded image
"""
import asyncio
import sys
from pathlib import Path
from datetime import datetime
# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent.parent))
from app.database import connect_db, disconnect_db, get_db
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# AIDA Bot configuration
AIDA_BOT_ID = "AIDA_BOT"
AIDA_AVATAR_URL = "https://imagedelivery.net/0utJlkqgAVuawL5OpMWxgw/3922956f-b69d-4cb3-97b9-3a185abec900/public"
async def update_aida_avatar():
"""Update AIDA_BOT avatar with the uploaded image"""
try:
# Connect to database
await connect_db()
db = await get_db()
# Update AIDA_BOT avatar
result = await db.users.update_one(
{"_id": AIDA_BOT_ID},
{"$set": {
"profilePicture": AIDA_AVATAR_URL,
"updated_at": datetime.utcnow()
}}
)
if result.modified_count > 0:
logger.info("βœ… AIDA_BOT avatar updated successfully")
else:
logger.warning("⚠️ No changes made (avatar may already be set)")
# Verify the update
aida_user = await db.users.find_one({"_id": AIDA_BOT_ID})
if aida_user:
logger.info(f"\n{'='*60}")
logger.info(f"βœ… AIDA Bot Profile:")
logger.info(f" ID: {AIDA_BOT_ID}")
logger.info(f" Name: {aida_user.get('name')}")
logger.info(f" Avatar: {aida_user.get('profilePicture')}")
logger.info(f"{'='*60}\n")
except Exception as e:
logger.error(f"Failed to update AIDA_BOT avatar: {e}")
raise
finally:
await disconnect_db()
if __name__ == "__main__":
logger.info("Updating AIDA_BOT avatar...")
asyncio.run(update_aida_avatar())