-
Notifications
You must be signed in to change notification settings - Fork 108
/
bot.js
256 lines (245 loc) · 8.66 KB
/
bot.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
/**
* InstagramBot.js
* =====================
* Instagram Bot made with love and nodejs
*
* @author: Patryk Rzucidlo [@ptkdev] <[email protected]> (https://ptkdev.it)
* @file: bot.js
* @version: 0.2
*
* @license: Code and contributions have 'GNU General Public License v3'
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @link Homepage: https://instagram-bot.js.ptkdev.io
* GitHub Repo: https://github.com/ptkdev/instagram-bot.js
*/
/**
* Libs
* =====================
* Open source library
*
* @author: Patryk Rzucidlo [@ptkdev] <[email protected]> (https://ptkdev.it)
* @license: This code and contributions have 'GNU General Public License v3'
* @version: 0.2
* @link: http://webdriver.io/
* @changelog: 0.1 initial release
* 0.2 refactor: removed useless vars
*
*/
const webdriverio = require('webdriverio');
const path = require('path');
const fs = require('fs');
const config = require(__dirname + '/config');
const options = {
desiredCapabilities: {
browserName: config.selenium_browser,
chromeOptions: {
args: config.selenium_chrome_options
},
binary: config.selenium_chrome_path,
host: config.selenium_host,
port: config.selenium_port
}
};
/**
* Init
* =====================
* Get username, password and hashtag of bot from /config.js
* If not exist rename config.js.tmpl to config.js and change strings
*
* @author: Patryk Rzucidlo [@ptkdev] <[email protected]> (https://ptkdev.it)
* @license: This code and contributions have 'GNU General Public License v3'
* @version: 0.1
* @changelog: 0.1 initial release
*
*/
let client = webdriverio.remote(options);
var bot = client.init();
/**
* Import libs
* =====================
* Flow and utilty modules
*
* @author: Patryk Rzucidlo [@ptkdev] <[email protected]> (https://ptkdev.it)
* @license: This code and contributions have 'GNU General Public License v3'
* @version: 0.2
* @changelog: 0.1 initial release
* 0.2 refactor: removed eval() and added require.
*
*/
let utils = require(__dirname + '/modules/utils.js')(bot, config);
/**
* Start Bot (init vars)
* =====================
*
* @author: Patryk Rzucidlo [@ptkdev] <[email protected]> (https://ptkdev.it)
* @license: This code and contributions have 'GNU General Public License v3'
* @version: 0.1
* @changelog: 0.1 initial release
*
*/
let login_status = "";
let twofa_status = "";
let like_status = "";
let pin_status = "";
/**
* Switch Mode
* =====================
* Switch mode from config.js
*
* @author: Patryk Rzucidlo [@ptkdev] <[email protected]> (https://ptkdev.it)
* @license: This code and contributions have 'GNU General Public License v3'
* @version: 0.1
* @changelog: 0.1 initial release
*
*/
async function switch_mode(bot, config, utils) {
if (config.bot_mode == "likemode_classic")
await start_likemode_classic(bot, config, utils);
}
/**
* LikemodeClassic Flow
* =====================
* /modules/likemode_classic.js
*
* @author: Patryk Rzucidlo [@ptkdev] <[email protected]> (https://ptkdev.it)
* @license: This code and contributions have 'GNU General Public License v3'
* @version: 0.1
* @changelog: 0.1 initial release
*
*/
async function start_likemode_classic(bot, config, utils) {
let likemode_classic = require(__dirname + '/modules/likemode_classic.js')(bot, config, utils);
utils.logger("[INFO]", "likemode", "classic");
let today = "";
let t1, t2, sec;
do {
today = new Date();
t1 = new Date(today.getFullYear(), today.getMonth(), today.getDate(), today.getHours(), today.getMinutes(), today.getSeconds());
utils.logger("[INFO]", "like", "loading... " + new Date(today.getFullYear(), today.getMonth(), today.getDate(), today.getHours(), today.getMinutes(), today.getSeconds()));
likemode_classic.like_open_hashtagpage();
utils.sleep(utils.random_interval(4, 8));
await likemode_classic.like_get_urlpic();
utils.sleep(utils.random_interval(4, 8));
like_status = await likemode_classic.like_click_heart();
today = new Date();
t2 = new Date(today.getFullYear(), today.getMonth(), today.getDate(), today.getHours(), today.getMinutes(), today.getSeconds());
sec = Math.abs((t1.getTime() - t2.getTime())/ 1000);
utils.logger("[INFO]", "likemode", "seconds of loop "+sec+"... for miss ban bot wait "+(90 - sec)+"-"+(90 - sec + 15));
if(sec < 90)
utils.sleep(utils.random_interval(90 - sec, (90 - sec + 15)));
} while (true);
}
/**
* 2FA Flow (check if work)
* =====================
* /modules/2FA.js
*
* @author: Patryk Rzucidlo [@ptkdev] <[email protected]> (https://ptkdev.it)
* @license: This code and contributions have 'GNU General Public License v3'
* @version: 0.1
* @changelog: 0.1 initial release
*
*/
async function start_twofa_check() {
utils.logger("[INFO]", "twofa", "instagram request pin?");
try {
let attr = await bot.getAttribute('#choice_1', 'value');
if (config.debug == true)
utils.logger("[DEBUG]", "twofa", "attr = " + attr);
utils.logger("[INFO]", "twofa", "yes, instagram require security pin... You can not pass!1!111! (cit.)");
utils.screenshot(bot, "twofa", "check_pin_request");
pin_status = 1;
} catch (err) {
if (config.debug == true)
utils.logger("[DEBUG]", "twofa", err);
utils.logger("[INFO]", "twofa", "no, bot is at work (started)... Wait...");
utils.logger("[INFO]", "twofa", "starting current mode");
utils.screenshot(bot, "twofa", "check_nopin");
pin_status = 0;
}
}
/**
* 2FA Flow
* =====================
* /modules/2FA.js
*
* @author: Patryk Rzucidlo [@ptkdev] <[email protected]> (https://ptkdev.it)
* @license: This code and contributions have 'GNU General Public License v3'
* @version: 0.1
* @changelog: 0.1 initial release
*
*/
async function start_twofa() {
let twofa = require(__dirname + '/modules/2FA.js')(bot, config, utils);
utils.logger("[INFO]", "twofa", "loading...");
twofa.sendpin();
utils.sleep(utils.random_interval(170, 180));
twofa.readpin();
utils.sleep(utils.random_interval(4, 8));
twofa.submit();
utils.sleep(utils.random_interval(4, 8));
twofa_status = await twofa.submitverify();
utils.sleep(utils.random_interval(4, 8));
bot = twofa.get_bot();
}
/**
* Login Flow
* =====================
* /modules/likemode_login.js
*
* @author: Patryk Rzucidlo [@ptkdev] <[email protected]> (https://ptkdev.it)
* @license: This code and contributions have 'GNU General Public License v3'
* @version: 0.1
* @changelog: 0.1 initial release
*
*/
async function start_login() {
let login = require(__dirname + '/modules/login.js')(bot, config, utils);
utils.logger("[INFO]", "login", "loading...");
login.open_loginpage(utils);
utils.sleep(utils.random_interval(4, 8));
login.set_username();
utils.sleep(utils.random_interval(4, 8));
login.set_password();
utils.sleep(utils.random_interval(4, 8));
login.submit();
utils.sleep(utils.random_interval(4, 8));
login_status = await login.submitverify();
utils.logger("[INFO]", "login", "login_status is " + login_status);
bot = login.get_bot();
}
/**
* Start Bot (flow)
* =====================
*
* @author: Patryk Rzucidlo [@ptkdev] <[email protected]> (https://ptkdev.it)
* @license: This code and contributions have 'GNU General Public License v3'
* @version: 0.1
* @changelog: 0.1 initial release
*
*/
start_login();
utils.sleep(utils.random_interval(4, 8));
if (login_status == 1) {
start_twofa_check();
utils.sleep(utils.random_interval(4, 8));
if (pin_status == 1) {
utils.sleep(utils.random_interval(4, 8));
start_twofa();
if (twofa_status == 1) {
switch_mode(bot, config, utils);
}
} else {
switch_mode(bot, config, utils);
}
}