-
Notifications
You must be signed in to change notification settings - Fork 4
/
flaauto.js
176 lines (162 loc) · 5.06 KB
/
flaauto.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
'use strict'
const Client = require('instagram-private-api').V1;
const chalk = require('chalk');
const delay = require('delay');
const _ = require('lodash');
const inquirer = require('inquirer');
const question = [
{
type:'input',
name:'username',
message:'[>] Insert Username:',
validate: function(value){
if(!value) return 'Can\'t Empty';
return true;
}
},
{
type:'password',
name:'password',
message:'[>] Insert Password:',
mask:'*',
validate: function(value){
if(!value) return 'Can\'t Empty';
return true;
}
},
{
type:'input',
name:'locationId',
message:'[>] Insert Location ID:',
validate: function(value){
value = value.match(/[0-9]/);
if (value) return true;
return 'Delay is number';
}
},
{
type:'input',
name:'text',
message:'[>] Insert Text Comment (Use [|] if more than 1):',
validate: function(value){
if(!value) return 'Can\'t Empty';
return true;
}
},
{
type:'input',
name:'sleep',
message:'[>] Insert Sleep (MiliSeconds):',
validate: function(value){
value = value.match(/[0-9]/);
if (value) return true;
return 'Delay is number';
}
}
]
const doLogin = async (params) => {
const Device = new Client.Device(params.username);
const Storage = new Client.CookieMemoryStorage();
const session = new Client.Session(Device, Storage);
try {
await Client.Session.create(Device, Storage, params.username, params.password)
const account = await session.getAccount();
return Promise.resolve({session,account});
} catch (err) {
return Promise.reject(err);
}
}
const grabFollowers = async (session, id) => {
const feed = new Client.Feed.AccountFollowers(session, id);
try{
feed.map = item => item.params;
return Promise.resolve(feed.all());
}catch (e){
return Promise.reject(err);
}
}
const doFollow = async (session, id) => {
try {
await Client.Relationship.create(session, id);
return true;
} catch (e) {
return false;
}
}
const doComment = async (session, id, text) => {
try {
await Client.Comment.create(session, id, text);
return true;
} catch(e){
return false;
}
}
const doLike = async (session, id) => {
try{
await Client.Like.create(session, id);
return true;
} catch(e) {
return false;
}
}
const doAction = async (session, params, text) => {
const task = [
doFollow(session, params.account.id),
doLike(session, params.id),
doComment(session, params.id, text)
];
var [Follow,Like,Comment] = await Promise.all(task);
Follow = Follow ? chalk`{bold.green SUKSES}` : chalk`{bold.red GAGAL}`;
Comment = Comment ? chalk`{bold.green SUKSES}` : chalk`{bold.red GAGAL}`;
Like = Like ? chalk`{bold.green SUKSES}` : chalk`{bold.red GAGAL}`;
return chalk`[Follow: ${Follow}] [Like: ${Like}] [Comment: ${Comment} ({cyan ${text}})]`;
}
const doMain = async (account, locationid, sleep, text) => {
console.log(chalk`\n{green [?] Try to Login ....}`);
account = await doLogin(account);
console.log(chalk`{bold.green [!] Login Success!}`)
const feed = new Client.Feed.LocationMedia(account.session, locationid);
console.log(chalk`{green [?] Try Follow, Like and Comment All Account In LocationId: ${locationid}\n}`);
try {
var cursor;
var count = 0;
do {
if (cursor) feed.setCursor(cursor);
count++;
const media = await feed.get();
console.log(chalk`[Cursor: {bold.cyan ${cursor ? cursor : 'null'}} | Count: {bold.cyan ${count}} | Total Media: {bold.cyan ${media.length}} | Delay: ${sleep} MiliSeconds ]`);
var timeNow = new Date();
timeNow = `${timeNow.getHours()}:${timeNow.getMinutes()}:${timeNow.getSeconds()}`
await Promise.all(media.map(async(media)=>{
const ranText = text[Math.floor(Math.random() * text.length)];
const resultAction = await doAction(account.session, media.params, ranText);
console.log(chalk`[{magenta ${timeNow}}] ${media.id} | {cyanBright @${media.params.account.username}} => ${resultAction}`);
}))
await delay(sleep);
cursor = await feed.getCursor();
} while(feed.isMoreAvailable());
} catch(e) {
console.log(e);
}
}
console.log(chalk`
{bold.cyan
—————————————————— [INFORMATION] ————————————————————
[?] {bold.green FLA | Using Location Media Target!}
—————————————————— [THANKS TO] ————————————————————
[✓] CODE BY CYBER SCREAMER CCOCOT (ccocot@bc0de.net)
[✓] FIXING & TESTING BY SYNTAX (@officialputu_id)
[✓] CCOCOT.CO | BC0DE.NET | NAONLAH.NET | WingkoColi
[✓] SGB TEAM REBORN | Zerobyte.id | ccocot@bc0de.net
—————————————————————————————————————————————————————}
`);
inquirer.prompt(question)
.then(answers => {
var text = answers.text.split('|');
doMain({
username:answers.username,
password:answers.password}, answers.locationId, answers.sleep, text);
})
.catch(e => {
console.log(e);
})