This repository has been archived by the owner on Aug 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flmauto.js
227 lines (207 loc) · 6.34 KB
/
flmauto.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
const Client = require('instagram-private-api').V1;
const delay = require('delay');
const chalk = require('chalk');
const _ = require('lodash');
const rp = require('request-promise');
const inquirer = require('inquirer');
const User = [
{
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:'target',
message:'[>] Insert Link Media:',
validate: function(value){
if(!value) return 'Can\'t Empty';
return true;
}
},
{
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:'mysyntx',
message:'[>] Input Total of Target You Want (ITTYW):',
validate: function(value){
value = value.match(/[0-9]/);
if (value) return true;
return 'Use Number Only!';
}
},
{
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 Login = async function(User){
const Device = new Client.Device(User.username);
const Storage = new Client.CookieMemoryStorage();
const session = new Client.Session(Device, Storage);
try {
await Client.Session.create(Device, Storage, User.username, User.password)
const account = await session.getAccount();
return Promise.resolve({session,account});
} catch (err) {
return Promise.reject(err);
}
}
const Target = async function(link){
const url = link+'?__a=1'
const option = {
url: url,
method: 'GET',
json:true
}
try{
const account = await rp(option);
return Promise.resolve(account.graphql.shortcode_media.id);
} catch (err){
return Promise.reject(err);
}
}
async function ngefollow(session,accountId){
try {
await Client.Relationship.create(session, accountId);
return true
} catch (e) {
return false
}
}
async function ngeComment(session, id, text){
try {
await Client.Comment.create(session, id, text);
return true;
} catch(e){
return false;
}
}
async function ngeLike(session, id){
try{
await Client.Like.create(session, id)
return true;
} catch(e) {
return false;
}
}
const CommentAndLike = async function(session, accountId, text){
var result;
const feed = new Client.Feed.UserMedia(session, accountId);
try {
result = await feed.get();
} catch (err) {
return chalk`{bold.red ${err}}`;
}
if (result.length > 0) {
const task = [
ngefollow(session, accountId),
ngeComment(session, result[0].params.id, text),
ngeLike(session, result[0].params.id)
]
const [Follow,Comment,Like] = await Promise.all(task);
const printFollow = Follow ? chalk`{green Follow}` : chalk`{red Follow}`;
const printComment = Comment ? chalk`{green Comment}` : chalk`{red Comment}`;
const printLike = Like ? chalk`{green Like}` : chalk`{red Like}`;
return chalk`{bold.green ${printFollow},${printComment},${printLike} [${text}]}`;
}
return chalk`{bold.cyan Timeline Kosong (SKIPPED)}`
};
const Followers = async function(session, id){
const feed = new Client.Feed.AccountFollowers(session, id);
try{
const Pollowers = [];
var cursor;
do {
if (cursor) feed.setCursor(cursor);
const getPollowers = await feed.get();
await Promise.all(getPollowers.map(async(akun) => {
Pollowers.push(akun.id);
}))
cursor = await feed.getCursor();
} while(feed.isMoreAvailable());
return Promise.resolve(Pollowers);
} catch(err){
return Promise.reject(err);
}
}
const Excute = async function(User, TargetUsername, Text, Sleep, mysyntx){
try {
console.log(chalk`{yellow \n [?] Try to Login . . .}`)
const doLogin = await Login(User);
console.log(chalk`{green [!] Login Succsess, }{yellow [?] Try To Get Link & Media ID Target . . .}`)
const getTarget = await Target(TargetUsername);
console.log(chalk`{green [!] ${TargetUsername} [${getTarget}]}`);
const getFollowers = await Followers(doLogin.session, doLogin.account.id);
console.log(chalk`{cyan [?] Try to Follow, Comment, and Like Followers Target . . . \n}`)
var TargetResult = await Client.Media.likers(doLogin.session, getTarget);
TargetResult = _.chunk(TargetResult, mysyntx);
for (var i = 0; i < TargetResult.length; i++) {
var timeNow = new Date();
timeNow = `${timeNow.getHours()}:${timeNow.getMinutes()}:${timeNow.getSeconds()}`
await Promise.all(TargetResult[i].map(async(akun) => {
if (!getFollowers.includes(akun.id) && akun.params.isPrivate === false) {
var ranText = Text[Math.floor(Math.random() * Text.length)];
const ngeDo = await CommentAndLike(doLogin.session, akun.id, ranText)
console.log(chalk`[{magenta ${timeNow}}] {bold.green [>]} @${akun.params.username} => ${ngeDo}`)
} else {
console.log(chalk`[{magenta ${timeNow}}] {bold.yellow [SKIPPED]}${akun.params.username} => PRIVATE OR ALREADY FOLLOWED`)
}
}));
console.log(chalk`{yellow \n [#][>] Delay For ${Sleep} MiliSeconds [<][#] \n}`);
await delay(Sleep);
}
} catch (err) {
console.log(err);
}
}
console.log(chalk`
{bold.cyan
—————————————————— [INFORMATION] ————————————————————
[?] {bold.green FLMauto | Using Media/Link 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
—————————————————————————————————————————————————————
What's new?
1. Input Target/delay Manual (ITTYW)
—————————————————————————————————————————————————————}
`);
inquirer.prompt(User)
.then(answers => {
var text = answers.text.split('|');
Excute({
username:answers.username,
password:answers.password
},answers.target,text,answers.sleep,answers.mysyntx);
})