-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
32 lines (30 loc) · 1.19 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
const instagramLogin = require("./src/instagramLogin.js");
const fs = require("fs");
const profileAPIs = require("./src/profileAPIs.js");
class client extends profileAPIs {
async init({username, password, cookie, saveCookie}) {
this.username = username;
this.password = password;
this.cookie =
cookie == "" || cookie === undefined
? await new instagramLogin(this.username, this.password).start()
: cookie;
let filePath = "./sessions.json";
saveCookie?(
() => {
if (fs.existsSync(filePath)) {
let data = JSON.parse(fs.readFileSync(filePath, "utf8"));
!data[`${username}`].includes(cookie) ? data[`${username}`].push(cookie) : null;
fs.writeFileSync(filePath, JSON.stringify(data))
}
else {
let data = { [username]: [cookie] };
fs.writeFileSync(filePath, JSON.stringify(data))
}
}
)() : null;
super.initialize(this.cookie);
console.log("Logged In..");
}
}
module.exports = client;