forked from rgasparin/conteudo_youtube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_chat_id_telegram.html
45 lines (40 loc) · 976 Bytes
/
get_chat_id_telegram.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
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
var token = $('#token_bot').val();
console.log(token);
if(token != null && token != "") {
getChatId(token);
} else {
alert("Preencha o token para iniciar o processo");
}
});
function getChatId(token) {
try {
$.get("https://api.telegram.org/bot"+token+"/getUpdates", function(data){
if(data.result.length > 0){
$('#chat_id').append(" "+data.result[0].message.chat.id);
} else {
getChatId(token);
}
}).fail(function() {
console.log( "error" );
getChatId(token);
});
} catch(e) {
getChatId(token);
}
}
});
</script>
</head>
<body>
<input type="text" placeholder="token chatbot" id="token_bot" />
<p id="chat_id"> Chat Id: </p>
<button>Pega Chat ID </button>
</body>
</html>