-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
89 lines (77 loc) · 2.78 KB
/
index.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const DISCORD_WEBHOOK_URL = ''; // Replace with your Discord webhook URL
const apiKey = '' // replace with your api key from friend tech.
const delay = 1000; // 1 second delay between each request
const express = require('express');
const axios = require('axios');
const app = express();
const PORT = process.env.PORT || 3000;
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
let usernames = [];
let config = {
method: 'get',
maxBodyLength: Infinity,
headers: {
'Authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZGRyZXNzIjoiMHhmYmFhN2VlNWMzNTJiYWI4ZTNjOWFkNGNmNTRmMzI0YTQ0NWM1YmQ3IiwiaWF0IjoxNjkyNzU1NTQxLCJleHAiOjE2OTUzNDc1NDF9.bl9dD-glwzlmJcv58GjQmgWCHFLVfn-SwdnO1QQynwo',
'Content-Type': 'application/json',
'Accept': 'application/json',
'Referer': 'https://www.friend.tech/'
}
};
async function sendToDiscord(username, address) {
try {
const response = await axios.post(DISCORD_WEBHOOK_URL, {
embeds: [{
title: "New Signup at Friend Tech",
color: 0x0099ff,
fields: [{
name: "Username",
value: username,
inline: false
}, {
name: "Address",
value: address,
inline: false
}],
timestamp: new Date()
}]
});
console.log("Response:", response.data);
} catch (error) {
console.error("Error sending embed:", error);
}
}
async function test(username, index) {
config.url = `https://prod-api.kosetto.com/search/users?username=${username}`;
let response = await axios.request(config);
for (let i = 0; i < response.data.users.length; i++) {
if (response.data.users[i].twitterUsername === username) {
console.log(`${response.data.users[i].twitterUsername} has signed up to friend tech`);
await sendToDiscord(response.data.users[i].twitterUsername, response.data.users[i].address);
usernames.splice(index, 1); // Remove the username from the array
return;
}
}
}
app.post('/addUsername', (req, res) => {
const { username } = req.body;
if (username) {
usernames.push(username);
res.status(200).send('Username added successfully.');
} else {
res.status(400).send('Username field is required.');
}
});
let currentIndex = 0;
const intervalId = setInterval(() => {
if (usernames.length === 0) return;
if (currentIndex >= usernames.length) {
currentIndex = 0;
}
test(usernames[currentIndex], currentIndex)
.catch(err => console.error(`An error occurred: ${err}`));
currentIndex++;
}, delay);
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});