-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
124 lines (112 loc) · 4.14 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bot Telegram Control Panel</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/milligram@1.4.1/dist/milligram.min.css">
<style>
label {
display: inline-block;
}
body {
background-color: #1f1f1f;
color: #fff;
}
button:hover {
background-color: #8842b3;
}
input, textarea {
color: #fff;
resize: vertical;
}
</style>
</head>
<body>
<h1>EscarBot</h1>
<form action="/setLinks" id="linkForm">
<label>
<input type="checkbox" id="linkToggle" name="toggle"{{ if .LinkDetection }} checked{{ end }}>
Link detection in group messages
</label>
</form>
<form action="/setChannelForward" id="channelForwardForm">
<label>
<input type="checkbox" id="channelForwardToggle" name="toggle"{{ if .ChannelForward }} checked{{ end }}>
Message forwarding (channel)
</label>
</form>
<form action="/setAdminForward" id="adminForwardForm">
<label>
<input type="checkbox" id="adminForwardToggle" name="toggle"{{ if .AdminForward }} checked{{ end }}>
Message forwarding (admin)
</label>
</form>
<form action="/setChannel" id="channelForm">
<label>
Channel ID:
<input type="text" id="channelId" name="id" value="{{ .ChannelID }}" required>
</label>
<button type="submit">Change</button>
</form>
<form action="/setGroup" id="groupForm">
<label>
Group ID:
<input type="text" id="groupId" name="id" value="{{ .GroupID }}" required>
</label>
<button type="submit">Change</button>
</form>
<form action="/setAdmin" id="adminForm">
<label>
Admin ID:
<input type="text" id="adminId" name="id" value="{{ .AdminID }}" required>
</label>
<button type="submit">Change</button>
</form>
<form id="messageForm">
<label for="customMessage">Custom Message:</label>
<textarea id="customMessage" name="customMessage" rows="4" required></textarea>
<label>
Recipient:
<input type="text" id="recipientId" name="recipientId" value="{{ .GroupID }}" required>
</label>
<button id="customMessageButton">Send</button>
</form>
<script>
const sendMessageUrl = "https://api.telegram.org/bot{{ .Bot.Token }}/sendMessage"
const messageParams = new URLSearchParams({
"text": "",
"chat_id": "",
"reply_to_message_id": "",
"parse_mode": "markdown",
"disable_web_page_preview": "false",
"disable_notification": "false",
})
const customMessageBox = document.getElementById("customMessage");
function handleToggle(toggleId, formId) {
document.getElementById(toggleId).addEventListener('change', () => {
document.getElementById(formId).submit();
});
}
handleToggle('linkToggle', 'linkForm');
handleToggle('channelForwardToggle', 'channelForwardForm');
handleToggle('adminForwardToggle', 'adminForwardForm');
document.getElementById("customMessageButton").addEventListener("click", (event) => {
event.preventDefault()
const value = customMessageBox.value;
const recipient = document.getElementById("recipientId").value;
messageParams.set("text", value);
messageParams.set("chat_id", recipient);
const request_url = sendMessageUrl + "?" + messageParams;
console.log(request_url);
fetch(request_url).then((response) => {
response.json().then((data) => {
console.log(data);
if (data.ok) customMessageBox.value = "";
else alert(data.description);
})
})
})
</script>
</body>
</html>