-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
74 lines (69 loc) · 3.46 KB
/
index.html
File metadata and controls
74 lines (69 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Отмазка за звёздочку</title>
<style>
body {font-family: Arial, sans-serif; text-align: center; padding: 20px;}
button {padding: 10px 20px; font-size: 16px; cursor: pointer;}
#excuse {margin-top: 20px; font-size: 18px; color: #555; min-height: 40px;}
</style>
</head>
<body>
<h1>Получи отмазку за 1★</h1>
<button id="payBtn">Получить отмазку</button>
<div id="excuse"></div>
<script>
// Initialize Telegram WebApp
if (!window.Telegram || !window.Telegram.WebApp) {
document.body.innerHTML = '<p>Ошибка: приложение должно запускаться внутри Telegram.</p>';
} else {
const tg = window.Telegram.WebApp;
tg.expand(); // открыть на всю высоту
tg.MainButton.setText('Закрыть');
tg.MainButton.hide();
// Список отговорок
const excuses = [
"Мой кот заблокировал клавиатуру.",
"Вдруг стало темно, и я испугался(ась).",
"Соседи сверху залили водой, я спасал(а) технику.",
"Мне позвонили из будущего и попросили не отвлекаться.",
"У меня случился временной парадокс.",
"Я решил(а) следовать зову пустыни.",
"Мой роутер внезапно стал поэтом и потребовал вдохновения.",
"Слишком много идей, мозг перегрелся.",
"Надо было выгуливать своего внутреннего единорога.",
"Я ждал(а) знака от Вселенной — он пришёл слишком поздно."
];
document.getElementById('payBtn').addEventListener('click', () => {
// Отправляем инвойс за 1 звезду
tg.openInvoice({
currency: 'XTR', // Telegram Stars
prices: [{ label: 'Одна отмазка', amount: 1 }],
payload: 'excuse_payload',
provider_token: '', // пустой для Stars
need_name: false,
need_phone: false,
need_email: false,
need_shipping_address: false,
is_flexible: false
});
});
// Обработка закрытия инвойса
tg.onEvent('invoice_closed', (event) => {
if (event.success) {
const random = excuses[Math.floor(Math.random() * excuses.length)];
document.getElementById('excuse').textContent = random;
tg.MainButton.show();
} else {
document.getElementById('excuse').textContent = 'Платёж отменён или не удался.';
}
});
// Кнопка MainButton для закрытия
tg.onEvent('mainButtonClicked', () => {
tg.close();
});
}
</script>
</body>
</html>