import os

bot_file = r"C:\Users\ahmed\Downloads\smartlogicchatbot\bot.php"
config_file = r"C:\Users\ahmed\Downloads\smartlogicchatbot\config.php"

# Fix config.php
with open(config_file, "r", encoding="utf-8") as f:
    cfg = f.read()

old_prices = """    'service_prices' => [
        'marketing' => 'يبدأ من 8,000 جنيه',
        'website' => 'يبدأ من 12,000 جنيه',
        'odoo_erp_crm' => 'يبدأ من 30,000 جنيه',
        'chatbot_automation' => '2,000 جنيه إنشاء + 1,000 جنيه شهريًا',
    ],"""
new_prices = """    'service_prices' => [
        'marketing' => 'يبدأ من 5,000 جنيه شهرياً',
        'website' => 'يبدأ من 10,000 جنيه حتى 25,000 جنيه',
        'odoo_erp_crm' => 'يبدأ من 18,000 جنيه',
        'chatbot_automation' => '2,000 جنيه إنشاء + 1,000 جنيه شهريًا',
    ],"""

if old_prices in cfg:
    cfg = cfg.replace(old_prices, new_prices)
    with open(config_file, "w", encoding="utf-8") as f:
        f.write(cfg)

# Fix bot.php (Make prompt read from config)
with open(bot_file, "r", encoding="utf-8") as f:
    bot = f.read()

old_prompt = """الأسعار المعتمدة عند السؤال:
- التسويق يبدأ من 8,000 جنيه.
- الموقع يبدأ من 12,000 جنيه.
- Odoo/ERP يبدأ من 30,000 جنيه."""

new_prompt = """الأسعار المعتمدة عند السؤال:
- التسويق يبدأ من 5,000 جنيه شهرياً.
- الموقع يبدأ من 10,000 جنيه حتى 25,000 جنيه.
- Odoo/ERP يبدأ من 18,000 جنيه."""

if old_prompt in bot:
    bot = bot.replace(old_prompt, new_prompt)
    with open(bot_file, "w", encoding="utf-8") as f:
        f.write(bot)

print("Pricing fixed.")
