const channelUsername = 'iraqborsa'; let currentIqdRate: number | null = null; let currentRmbRate: number | null = null; export async function initTelegramAuth() { console.log('Initializing Rates Fetchers...'); // Initial fetch await Promise.all([ fetchLatestRate(), fetchFrankfurterRates() ]); // Fetch rate every 24 hours setInterval(() => { fetchLatestRate(); fetchFrankfurterRates(); }, 24 * 60 * 60 * 1000); } export async function fetchLatestRate() { try { console.log(`Fetching latest messages from https://t.me/s/${channelUsername}...`); const response = await fetch(`https://t.me/s/${channelUsername}`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const html = await response.text(); const regex = /
{ console.log("Setup complete! You can press Ctrl+C to exit and start the main server."); // Process will keep running due to setInterval }).catch(console.error); }