ready site

This commit is contained in:
Bivekich
2025-02-07 02:17:28 +03:00
parent a390ab919c
commit 9b75339c1e
42 changed files with 11112 additions and 0 deletions

31
lib/telegram.ts Normal file
View File

@ -0,0 +1,31 @@
import { TELEGRAM_CONFIG } from './config';
export async function sendTelegramNotification(phone: string, source: string) {
const text = `🔔 Новая заявка!\n\n📱 Телефон: ${phone}\n📍 Источник: ${source}`;
try {
const response = await fetch(
`https://api.telegram.org/bot${TELEGRAM_CONFIG.BOT_TOKEN}/sendMessage`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
chat_id: TELEGRAM_CONFIG.CHAT_ID,
text: text,
parse_mode: 'HTML',
}),
}
);
if (!response.ok) {
throw new Error('Failed to send Telegram notification');
}
return true;
} catch (error) {
console.error('Error sending Telegram notification:', error);
return false;
}
}