-
Notifications
You must be signed in to change notification settings - Fork 692
/
heroku_atiban.js
67 lines (53 loc) · 1.9 KB
/
heroku_atiban.js
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
// heroku_antiban.js
// Function to check if the bot is safely running on Heroku
function isHeroku() {
return window.location.hostname === 'heroku.com';
}
// Function to simulate a user interaction to prevent Heroku's idle timeout
function keepAlive() {
if (isHeroku()) {
// Simulate a user interaction by sending a start message to the bot
// Replace 'NUMERO_OWNER' with the actual phone number of your bot
const message = 'ping';
const url = `https://api.whatsapp.com/send?phone=your_bot_phone_number&text=${message}`;
fetch(url)
.then(response => {
if (!response.ok) {
console.error('Error sending keep-alive message:', response.statusText);
}
})
.catch(error => {
console.error('Error sending keep-alive message:', error);
});
}
}
// Set up an interval to periodically send keep-alive messages
setInterval(keepAlive, 30 * 60 * 1000); // Send a start message every 30 minutes
}));
/*
// heroku_antiban.js
// Function to check if the bot is safely running on Heroku
function isHeroku() {
return window.location.hostname === 'heroku.com';
}
// Function to simulate a user interaction to prevent Heroku's idle timeout
function keepAlive() {
if (isHeroku()) {
// Simulate a user interaction by sending a message to the bot
// Replace 'your_bot_phone_number' with the actual phone number of your bot
const message = 'ping';
const url = `https://api.whatsapp.com/send?phone=your_bot_phone_number&text=${message}`;
fetch(url)
.then(response => {
if (!response.ok) {
console.error('Error sending keep-alive message:', response.statusText);
}
})
.catch(error => {
console.error('Error sending keep-alive message:', error);
});
}
}
// Set up an interval to periodically send keep-alive messages
setInterval(keepAlive, 30 * 60 * 1000); // Send a message every 30 minutes
*/