-
Notifications
You must be signed in to change notification settings - Fork 52
/
app.js
51 lines (47 loc) · 1.36 KB
/
app.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
const fs = require('fs');
const axios = require('axios');
let totalMessagesSent = 0;
async function sendMessages(urls, customText) {
try {
console.log(`Sending: "${customText}"`);
const requests = urls.map((url, index) =>
axios
.get(`${url}${encodeURIComponent(customText)}`)
.then((response) => {
if (response.status === 200) {
return `Link ${index + 1}: OK`;
} else {
return `Link ${index + 1}: Unexpected status code: ${response.status}`;
}
})
.catch((error) => {
return `Link ${index + 1}: API down!: ${error.message}`;
})
);
const results = await Promise.allSettled(requests);
results.forEach((result) => {
console.log(result.value);
});
totalMessagesSent++;
console.log(`Total messages sent: ${totalMessagesSent}`);
console.log('='.repeat(30));
} catch (error) {
console.error('Error:', error.message);
}
}
async function main() {
try {
const urls = fs
.readFileSync('urls.txt', 'utf8')
.trim()
.split('\n');
const customText = 'Bismillah Mati'; // Custom text
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
while (true) {
await sendMessages(urls, customText);
}
} catch (error) {
console.error('Error:', error.message);
}
}
main();