<?php
// secret/bot_tele.php

function sendTelegramNotif($type, $message, $customPhoto = null) {
    $botToken = "8583444211:AAGvi4iLX-amtyFf6W_GQmPXH0jVFqU1SN8"; // Ganti dengan Token Bot Anda
    
    // 1. Konfigurasi ID Grup
    $groups = [
        'main'    => '-1003665896911', // Grup 1: Withdraw & New Member
        'deposit' => '-1003665896911'  // Grup 2: Khusus Deposit
    ];

    // 2. Konfigurasi Logo Berbeda per Kategori
    $logos = [
        'new_member' => 'https://idryerepay.com/assets/images/bot_newmember.png',
        'withdraw'   => 'https://idryerepay.com/assets/images/bot_withdraw.png',
        'deposit'    => 'https://idryerepay.com/assets/images/bot_deposit.png'
    ];

    $chatId = $groups[$type === 'deposit' ? 'deposit' : 'main'];
    
    // Pilih foto: Prioritas customPhoto -> Logo Kategori -> Logo Default
    $photoUrl = $customPhoto ?? ($logos[$type] ?? $logos['new_member']);
    
    $url = "https://api.telegram.org/bot" . $botToken . "/sendPhoto";
    
    $data = [
        'chat_id'    => $chatId,
        'photo'      => $photoUrl,
        'caption'    => $message,
        'parse_mode' => 'HTML'
    ];

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
    $result = curl_exec($ch);
    curl_close($ch);
    
    return $result;
}
?>