-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateProfile.js
57 lines (45 loc) · 1.35 KB
/
createProfile.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
import fetch from "node-fetch";
import chalk from "chalk";
import { faker } from '@faker-js/faker';
async function createProfile(accessToken) {
const username = genUsername();
const bio = genBio();
const url = "https://frontend-api.pump.fun/users";
const payload = {
"bio": bio,
"username": username,
};
const headers = {
"Cookie": `auth_token=${accessToken}`,
"Content-Type": "application/json"
}
const req = await fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
});
const res = await req.json();
if (!req.ok) {
console.error(chalk.redBright("Failed to create profile:", JSON.stringify(res, null, 2)));
return false;
}
console.log(chalk.greenBright(`Profile created \nUsername: ${res.username}\nBio: ${res.bio}`));
return true;
}
function genUsername() {
let username = '';
while (username.length === 0 || username.length > 10 || !/^[a-zA-Z0-9_]+$/.test(username)) {
username = faker.internet.userName().replace(/[^a-zA-Z0-9_]/g, '_');
}
return username;
}
function genBio() {
let bioList = [
'bio1',
'bio2',
'bio3'
];
let randomChoice = Math.floor(Math.random() * bioList.length);
return bioList[randomChoice];
}
export default createProfile;