forked from jaguar754/instabot.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
executable file
·316 lines (282 loc) · 9.67 KB
/
run.py
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import print_function
from src.unfollow_protocol import unfollow_protocol
from src.follow_protocol import follow_protocol
from src.feed_scanner import feed_scanner
from src.check_status import check_status
from src import InstaBot
import configparser
import os
import sys
import time
import json
import sys
import re
python_version_test = f"If you are reading this error, you are not running Python 3.6 or greater. Check 'python --version' or 'python3 --version'."
try:
from pip._internal import main
except:
print(">>> Please install the latest version of pip")
config_location = "config.ini"
config = configparser.ConfigParser()
def setupinteractive(config, config_location="config.ini"):
if os.path.isfile(config_location):
config.read(config_location)
configsettings = {
"password": "req",
"like_per_day": "opt",
"comments_per_day": "opt",
"max_like_for_one_tag": "opt",
"follow_per_day": "opt",
"follow_time": "opt",
"unfollow_per_day": "opt",
"unfollow_break_min": "opt",
"unfollow_break_max": "opt",
"tag_list": "opt",
}
config["DEFAULT"] = {
"username": "none",
"password": "none",
"like_per_day": 709,
"comments_per_day": 31,
"max_like_for_one_tag": 36,
"follow_per_day": 310,
"follow_time": 3600,
"unfollow_per_day": 297,
"unfollow_break_min": 3,
"unfollow_break_max": 17,
"log_mod": 0,
"proxy": "",
}
config["DEFAULT"]["comment_list"] = json.dumps(
[
["this", "the", "your"],
["photo", "picture", "pic", "shot", "snapshot"],
["is", "looks", "feels", "is really"],
[
"great",
"super",
"good",
"very good",
"good",
"wow",
"WOW",
"cool",
"GREAT",
"magnificent",
"magical",
"very cool",
"stylish",
"beautiful",
"so beautiful",
"so stylish",
"so professional",
"lovely",
"so lovely",
"very lovely",
"glorious",
"so glorious",
"very glorious",
"adorable",
"excellent",
"amazing",
],
[".", "..", "...", "!", "!!", "!!!"],
]
)
config["DEFAULT"]["tag_list"] = json.dumps(
["follow4follow", "f4f", "cute", "l:212999109"]
)
config["DEFAULT"]["tag_blacklist"] = json.dumps(["rain", "thunderstorm"])
config["DEFAULT"]["unwanted_username_list"] = json.dumps(
[
"second",
"stuff",
"art",
"project",
"love",
"life",
"food",
"blog",
"free",
"keren",
"photo",
"graphy",
"indo",
"travel",
"art",
"shop",
"store",
"sex",
"toko",
"jual",
"online",
"murah",
"jam",
"kaos",
"case",
"baju",
"fashion",
"corp",
"tas",
"butik",
"grosir",
"karpet",
"sosis",
"salon",
"skin",
"care",
"cloth",
"tech",
"rental",
"kamera",
"beauty",
"express",
"kredit",
"collection",
"impor",
"preloved",
"follow",
"follower",
"gain",
".id",
"_id",
"bags",
]
)
config["DEFAULT"]["unfollow_whitelist"] = json.dumps(
["example_user_1", "example_user_2"]
)
print(
"\n\n >>> Setup Wizard >>>\n________________________________________________"
)
confusername = None
while confusername is None or len(confusername) < 3:
confusername = str(input("Please enter the username you wish to configure: "))
if confusername is None or len(confusername) < 3:
print("This field is required.")
if confusername in config:
print("User already configured. Modifying...")
existing_user = True
else:
config.add_section(confusername)
existing_user = False
config[confusername]["username"] = confusername
print(" >>> TIP: Press Enter to skip and set default values")
for setting, reqset in configsettings.items():
requiredset = None
if existing_user:
prompt_text = "Previous set value: "
section = confusername
else:
prompt_text = "Enter for defaults: "
section = "DEFAULT"
while requiredset is None:
if reqset is "req":
confvar = input(f"Enter value for '{setting}' (Required): ")
if confvar == "":
print("This field is required")
else:
config[confusername][setting] = str(confvar)
requiredset = "done"
else:
if setting == "tag_list":
print(
"\n\nAttention!\n\nEnter the hashtags you would like to target separated with commas.\n For example:\n follow4follow, instagood, f2f, instalifo\n\n"
)
confvar = input("Enter tags (or skip to defaults): ")
else:
confvar = input(
f"Enter value for '{setting} ({prompt_text}{config[section][setting]}):"
)
if setting == "tag_list" and confvar != "":
confvar = re.sub(r"\s+", "", confvar)
confvar = re.sub(r"#", "", confvar)
tags_list = confvar.split(",")
config[confusername][setting] = str(json.dumps(tags_list))
elif confvar == "":
# print('Entering default: '+ config[section][setting])
if setting != "tag_list":
config[confusername][setting] = config[section][setting]
else:
config[confusername][setting] = str(confvar)
requiredset = "done"
print("\nWriting to file...")
with open(config_location, "w") as configfile:
config.write(configfile)
print("Config updated! Re-run script to login.")
exit()
if not os.path.isfile(config_location):
overwrite_answer = None
while overwrite_answer not in ("yes", "no", "n", "y"):
overwrite_answer = input(
"Config file does not exist. Would you like to setup now? (yes/no): "
)
if overwrite_answer == "no" or overwrite_answer == "n":
exit()
setupinteractive(config, config_location)
askusername = None
loaded_with_argv = False
try:
if len(sys.argv[1]) > 3:
askusername = sys.argv[1]
loaded_with_argv = True
except:
askusername = None
config.read(config_location)
if askusername is None:
askusername = input(
' _________LOGIN_________\n (To change user settings, type "config")\n\n Please enter your username: '
)
if askusername == "config":
setupinteractive(config, config_location)
elif askusername in config:
print(f" Loading settings for {askusername}!")
if loaded_with_argv is False:
try:
print(
f" (Tip: Log in directly by running '{sys.argv[0]} {askusername}')'"
)
except:
print(
" (Tip: Log in directly by appending your username at the end of the script)"
)
else:
if "yes" in input(
"Could not find user in settings. Would you like to add now? (yes/no): "
):
setupinteractive(config, config_location)
else:
exit()
usrconfig = askusername
print("\n\n >>> Starting bot >>>\n________________________________________________")
bot = InstaBot(
login=config[usrconfig]["username"],
password=config[usrconfig]["password"],
like_per_day=int(config[usrconfig]["like_per_day"]),
comments_per_day=int(config[usrconfig]["comments_per_day"]),
tag_list=json.loads(config[usrconfig]["tag_list"]),
tag_blacklist=json.loads(config[usrconfig]["tag_blacklist"]),
user_blacklist={},
max_like_for_one_tag=int(config[usrconfig]["max_like_for_one_tag"]),
follow_per_day=int(config[usrconfig]["follow_per_day"]),
follow_time=int(config[usrconfig]["follow_time"]),
unfollow_per_day=int(config[usrconfig]["unfollow_per_day"]),
unfollow_break_min=int(config[usrconfig]["unfollow_break_min"]),
unfollow_break_max=int(config[usrconfig]["unfollow_break_max"]),
log_mod=int(config[usrconfig]["log_mod"]),
proxy=config[usrconfig]["proxy"],
# List of list of words, each of which will be used to generate comment
# For example: "This shot feels wow!"
comment_list=json.loads(config[usrconfig]["comment_list"]),
# Use unwanted_username_list to block usernames containing a string
# Will do partial matches; i.e. 'mozart' will block 'legend_mozart'
# 'free_followers' will be blocked because it contains 'free'
unwanted_username_list=json.loads(config[usrconfig]["unwanted_username_list"]),
unfollow_whitelist=json.loads(config[usrconfig]["unfollow_whitelist"]),
database_name=f"{usrconfig}.db",
session_file=f"{usrconfig}.session",
)
while True:
bot.new_auto_mod()