-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
56 lines (53 loc) · 2.33 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Камень, Ножницы, Бумага</title>
<link rel="stylesheet" href="styles.css">
<script src="https://telegram.org/js/telegram-web-app.js"></script>
</head>
<body>
<div id="particles-js"></div>
<div class="game-container">
<div id="scoreboard"></div>
<div class="row" id="top-row">
<div class="card" data-type="rock"></div>
<div class="card" data-type="scissors"></div>
<div class="card" data-type="paper"></div>
</div>
<div class="row" id="bottom-row">
<div class="card" data-type="rock" onclick="playGame('rock')">Камень</div>
<div class="card" data-type="scissors" onclick="playGame('scissors')">Ножницы</div>
<div class="card" data-type="paper" onclick="playGame('paper')">Бумага</div>
</div>
</div>
<!-- Модальное окно с результатом -->
<div id="result-modal" class="modal hidden">
<div class="modal-content">
<p id="result-message"></p>
<button id="next-round-button" onclick="sendUserData()">Дальше</button>
</div>
</div>
<script src="particles.js"></script>
<script src="script.js" defer></script>
<script>
function sendUserData() {
// Получаем initData
//const initData = Telegram.WebApp.initData;
// Формируем данные для отправки на сервер бота
const botToken = "BOT_TOKEN";
const chatId = Telegram.WebApp.initDataUnsafe.user.id;
//const userName = Telegram.WebApp.initDataUnsafe.user.first_name;
// Формируем URL для отправки сообщения через API Telegram
const url = "https://api.telegram.org/bot${botToken}/sendMessage?chat_id=${chatId}&text=test";
// Отправляем запрос
fetch(url)
//.then(response => response.json())
//.then(data => console.log('Message sent:', data))
//.catch(error => console.error('Error:', error));
}
Telegram.WebApp.ready()
</script>
</body>
</html>